[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-18 Thread Wei Xiao via Phabricator via cfe-commits
wxiao3 added a comment.

Can anyone provide me some small reproducers code for the issue tripped over by 
Chromium / Skia?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


[PATCH] D57055: [RISCV] Mark TLS as supported

2019-06-18 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
Herald added subscribers: Jim, benna, psnobl.

LGTM, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D57055



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


[PATCH] D62738: [HIP] Support device_shadow variable

2019-06-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 205503.
yaxunl added a comment.

Fix visibility and dso_local. Allow undefined symbol in code object. This is to 
allow merging the host and device symbols at run time.


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

https://reviews.llvm.org/D62738

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/ToolChains/HIP.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/AST/ast-dump-cuda-device-shadow.cu
  test/CodeGenCUDA/device-shadow.cu
  test/Driver/hip-toolchain-no-rdc.hip
  test/Driver/hip-toolchain-rdc.hip
  test/Misc/pragma-attribute-supported-attributes-list.test

Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -26,6 +26,7 @@
 // CHECK-NEXT: CPUSpecific (SubjectMatchRule_function)
 // CHECK-NEXT: CUDAConstant (SubjectMatchRule_variable)
 // CHECK-NEXT: CUDADevice (SubjectMatchRule_function, SubjectMatchRule_variable)
+// CHECK-NEXT: CUDADeviceShadow (SubjectMatchRule_variable)
 // CHECK-NEXT: CUDAGlobal (SubjectMatchRule_function)
 // CHECK-NEXT: CUDAHost (SubjectMatchRule_function)
 // CHECK-NEXT: CUDALaunchBounds (SubjectMatchRule_objc_method, SubjectMatchRule_hasType_functionType)
Index: test/Driver/hip-toolchain-rdc.hip
===
--- test/Driver/hip-toolchain-rdc.hip
+++ test/Driver/hip-toolchain-rdc.hip
@@ -43,7 +43,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]]
 
-// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared"
+// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[OBJ_DEV1]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" 
@@ -75,7 +75,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV2:".*-gfx900-.*o"]]
 
-// CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared"
+// CHECK: [[LLD]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[OBJ_DEV2]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
Index: test/Driver/hip-toolchain-no-rdc.hip
===
--- test/Driver/hip-toolchain-no-rdc.hip
+++ test/Driver/hip-toolchain-no-rdc.hip
@@ -37,7 +37,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]]
 
-// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared"
+// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]]
 
 //
@@ -65,7 +65,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]]
 
-// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared"
+// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]]
 
 //
@@ -109,7 +109,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]]
 
-// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared"
+// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_B_803:.*out]]" [[OBJ_DEV_B_803]]
 
 //
@@ -137,7 +137,7 @@
 // CHECK-SAME: "-filetype=obj"
 // CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]]
 
-// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared"
+// CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_B_900:.*out]]" [[OBJ_DEV_B_900]]
 
 //
Index: test/CodeGenCUDA/device-shadow.cu
===
--- /dev/null
+++ test/CodeGenCUDA/device-shadow.cu
@@ -0,0 +1,28 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -std=c++11 -fcuda-is-device \
+// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CUDADEV %s
+// RUN: %clang_cc1 -triple x86_64 -std=c++11 \
+// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CUDAHOST %s
+
+// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -std=c++11 -fvisibility hidden -fapply-global-visibility-to-externs \
+// RUN: -emit-llvm -o - -x hip %s | FileCheck -check-prefixes=HIPDEV %s
+// RUN: %clang_cc1 -triple x86_64 -std=c++11 \
+// RUN: -emit-llvm -o - -x hip %s | FileCheck -check-prefixes=HIPHOST %s
+
+struct textureReference {
+  int a;
+};
+
+template 
+struct texture : public textureReference {
+texture() { a = 1; }
+};
+
+__attribute__((device_shadow)) texture tex;
+// CUDADEV-NOT: @tex
+// CUDAHOST-NOT: call i32 @__hipRegisterVar{{.*}}@tex
+// HIPDEV: @tex = external addrspace(1) global %struct.texture
+// HIPDEV-NOT: declare{{.*}}void 

[PATCH] D63497: Add support for openSUSE RISC-V triple

2019-06-18 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Thanks for the contribution! I'd recommend adding a skeleton toolchain dir 
structure to clang/test/Driver/Inputs and adding a test to 
clang/test/Driver/riscv64-toolchain.c. You should be able to see examples in 
test/Driver/Inputs.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63497



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


[PATCH] D63498: [RISC-V] Add -msave-restore and -mno-save-restore to clang driver

2019-06-18 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Can you add a CHECK line that shows the expected warning is emitted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63498



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


[PATCH] D57086: Ignore trailing NullStmts in StmtExprs for GCC compatibility

2019-06-18 Thread Dominic Ferreira via Phabricator via cfe-commits
domdom updated this revision to Diff 205501.
domdom added a comment.

clang-format the patch


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

https://reviews.llvm.org/D57086

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/AST/ast-dump-stmt.c
  clang/test/CodeGen/exprs.c
  clang/test/Sema/statements.c
  clang/test/SemaCXX/statements.cpp

Index: clang/test/SemaCXX/statements.cpp
===
--- clang/test/SemaCXX/statements.cpp
+++ clang/test/SemaCXX/statements.cpp
@@ -37,3 +37,18 @@
 
 struct MMX_t {};
 void test6() { __asm__("" : "=m"(*(MMX_t *)0)); }
+
+template 
+T test7(T v) {
+  return ({ // expected-warning{{use of GNU statement expression extension}}
+T a = v;
+a;
+;
+;
+  });
+}
+
+void test8() {
+  int a = test7(1);
+  double b = test7(2.0);
+}
Index: clang/test/Sema/statements.c
===
--- clang/test/Sema/statements.c
+++ clang/test/Sema/statements.c
@@ -119,3 +119,21 @@
 SIZE = sizeof(({unsigned long __ptr; __ptr;}))
   };
 }
+
+// GCC ignores empty statements at the end of compound expressions where the
+// result type is concerned.
+void test13() {
+  int a;
+  a = ({ 1; });
+  a = ({1;; });
+  a = ({int x = 1; (void)x; }); // expected-error {{assigning to 'int' from incompatible type 'void'}}
+  a = ({int x = 1; (void)x;; }); // expected-error {{assigning to 'int' from incompatible type 'void'}}
+}
+
+void test14() { return ({}); }
+void test15() {
+  return ({ });
+}
+void test16() {
+  return ({test:;; });
+}
Index: clang/test/CodeGen/exprs.c
===
--- clang/test/CodeGen/exprs.c
+++ clang/test/CodeGen/exprs.c
@@ -196,3 +196,13 @@
 }
 // CHECK-LABEL: define void @f18()
 // CHECK: call i32 @returns_int()
+
+// Ensure the right stmt is returned
+int f19() {
+  return ({ 3;;4;; });
+}
+// CHECK-LABEL: define i32 @f19()
+// CHECK: [[T:%.*]] = alloca i32
+// CHECK: store i32 4, i32* [[T]]
+// CHECK: [[L:%.*]] = load i32, i32* [[T]]
+// CHECK: ret i32 [[L]]
Index: clang/test/AST/ast-dump-stmt.c
===
--- clang/test/AST/ast-dump-stmt.c
+++ clang/test/AST/ast-dump-stmt.c
@@ -372,4 +372,14 @@
   // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 10
   // CHECK-NEXT: ImplicitCastExpr
   // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int' lvalue Var 0x{{[^ ]*}} 'a' 'int'
+  ({int a = 10; a;;; });
+  // CHECK-NEXT: StmtExpr 0x{{[^ ]*}}  'int'
+  // CHECK-NEXT: CompoundStmt
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}}  col:9 used a 'int' cinit
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 10
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}}  'int' lvalue Var 0x{{[^ ]*}} 'a' 'int'
+  // CHECK-NEXT: NullStmt
+  // CHECK-NEXT: NullStmt
 }
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -6604,13 +6604,13 @@
   bool IsStmtExpr) {
   Sema::CompoundScopeRAII CompoundScope(getSema());
 
+  const Stmt *ExprResult = S->getStmtExprResult();
   bool SubStmtInvalid = false;
   bool SubStmtChanged = false;
   SmallVector Statements;
   for (auto *B : S->body()) {
 StmtResult Result = getDerived().TransformStmt(
-B,
-IsStmtExpr && B == S->body_back() ? SDK_StmtExprResult : SDK_Discarded);
+B, IsStmtExpr && B == ExprResult ? SDK_StmtExprResult : SDK_Discarded);
 
 if (Result.isInvalid()) {
   // Immediately fail if this was a DeclStmt, since it's very
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13372,7 +13372,9 @@
   QualType Ty = Context.VoidTy;
   bool StmtExprMayBindToTemp = false;
   if (!Compound->body_empty()) {
-if (const auto *LastStmt = dyn_cast(Compound->body_back())) {
+// For GCC compatibility we get the last Stmt excluding trailing NullStmts.
+if (const auto *LastStmt =
+dyn_cast(Compound->getStmtExprResult())) {
   if (const Expr *Value = LastStmt->getExprStmt()) {
 StmtExprMayBindToTemp = true;
 Ty = Value->getType();
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -972,10 +972,16 @@
 StmtResult Parser::handleExprStmt(ExprResult E, ParsedStmtContext StmtCtx) {
   bool IsStmtExprResult = false;
   if ((StmtCtx & ParsedStmtContext::InStmtExpr) != ParsedStmtContext()) {
-// Look ahead to see if the next two tokens close the statement expression;
-

[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/AST/Decl.cpp:3937
+  // -- [has] virtual member functions or virtual base classes, or
+  // -- has subobjects of nonzero size or bit-fields of nonzero length
+  if (const auto *CXXRD = dyn_cast(RD)) {

rsmith wrote:
> rjmccall wrote:
> > Surely a bit-field of nonzero length is a subobject of nonzero size.
> Usually, but not if it's unnamed (unnamed bit-fields aren't subobjects). In 
> any case, this is a quote from the C++ standard.
Fair enough.



Comment at: lib/AST/Decl.cpp:3945
+return false;
+  }
+

rsmith wrote:
> rjmccall wrote:
> > Is this a C/C++ modules interaction?
> We don't allow C modules to be imported into C++ compilations or vice versa, 
> so this should be unreachable unless we start allowing the attribute in C. 
> Nice catch.
> 
> I guess the question is, then: should we allow this attribute in C (either 
> with a GNU `__attribute__` spelling or as a C20 `[[clang::attribute]]`)? I 
> don't think it's really useful in C (empty structs are ill-formed, and you 
> can't reuse tail padding because structs are always trivial, at least in 
> standard C), so I'm inclined to say no.
I agree that it seems relatively useless in C, and there's no reason to think 
they'd use this language design if they decided they did want it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451



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


[PATCH] D63535: [clang][AST] MangleUtil: A refactoring of CodegenNameGeneratorImpl (NFC).

2019-06-18 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi created this revision.
plotfi added reviewers: compnerd, ahatanak, akyrtzi, aaron.ballman.
Herald added subscribers: cfe-commits, arphaman, dexonsmith.
Herald added a project: clang.

CodegenNameGeneratorImpl is the most complete implementation of name mangling 
but it is in clang::Index. This makes it very difficult to use it elsewhere in 
clang. This is just a NFC refactoring  of CodegenNameGeneratorImpl into a class 
called MangleUtil. Other than the name and placement change there is no 
functional change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63535

Files:
  clang/include/clang/AST/Mangle.h
  clang/include/clang/Index/CodegenNameGenerator.h
  clang/lib/AST/Mangle.cpp
  clang/lib/Index/CodegenNameGenerator.cpp

Index: clang/lib/Index/CodegenNameGenerator.cpp
===
--- clang/lib/Index/CodegenNameGenerator.cpp
+++ clang/lib/Index/CodegenNameGenerator.cpp
@@ -14,7 +14,6 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
-#include "clang/AST/Mangle.h"
 #include "clang/AST/VTableBuilder.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/IR/DataLayout.h"
@@ -24,191 +23,9 @@
 using namespace clang;
 using namespace clang::index;
 
-struct CodegenNameGenerator::Implementation {
-  std::unique_ptr MC;
-  llvm::DataLayout DL;
-
-  Implementation(ASTContext )
-: MC(Ctx.createMangleContext()),
-  DL(Ctx.getTargetInfo().getDataLayout()) {}
-
-  bool writeName(const Decl *D, raw_ostream ) {
-// First apply frontend mangling.
-SmallString<128> FrontendBuf;
-llvm::raw_svector_ostream FrontendBufOS(FrontendBuf);
-if (auto *FD = dyn_cast(D)) {
-  if (FD->isDependentContext())
-return true;
-  if (writeFuncOrVarName(FD, FrontendBufOS))
-return true;
-} else if (auto *VD = dyn_cast(D)) {
-  if (writeFuncOrVarName(VD, FrontendBufOS))
-return true;
-} else if (auto *MD = dyn_cast(D)) {
-  MC->mangleObjCMethodNameWithoutSize(MD, OS);
-  return false;
-} else if (auto *ID = dyn_cast(D)) {
-  writeObjCClassName(ID, FrontendBufOS);
-} else {
-  return true;
-}
-
-// Now apply backend mangling.
-llvm::Mangler::getNameWithPrefix(OS, FrontendBufOS.str(), DL);
-return false;
-  }
-
-  std::string getName(const Decl *D) {
-std::string Name;
-{
-  llvm::raw_string_ostream OS(Name);
-  writeName(D, OS);
-}
-return Name;
-  }
-
-  enum ObjCKind {
-ObjCClass,
-ObjCMetaclass,
-  };
-
-  std::vector getAllManglings(const ObjCContainerDecl *OCD) {
-StringRef ClassName;
-if (const auto *OID = dyn_cast(OCD))
-  ClassName = OID->getObjCRuntimeNameAsString();
-else if (const auto *OID = dyn_cast(OCD))
-  ClassName = OID->getObjCRuntimeNameAsString();
-
-if (ClassName.empty())
-  return {};
-
-auto Mangle = [&](ObjCKind Kind, StringRef ClassName) -> std::string {
-  SmallString<40> Mangled;
-  auto Prefix = getClassSymbolPrefix(Kind, OCD->getASTContext());
-  llvm::Mangler::getNameWithPrefix(Mangled, Prefix + ClassName, DL);
-  return Mangled.str();
-};
-
-return {
-  Mangle(ObjCClass, ClassName),
-  Mangle(ObjCMetaclass, ClassName),
-};
-  }
-
-  std::vector getAllManglings(const Decl *D) {
-if (const auto *OCD = dyn_cast(D))
-  return getAllManglings(OCD);
-
-if (!(isa(D) || isa(D)))
-  return {};
-
-const NamedDecl *ND = cast(D);
-
-ASTContext  = ND->getASTContext();
-std::unique_ptr M(Ctx.createMangleContext());
-
-std::vector Manglings;
-
-auto hasDefaultCXXMethodCC = [](ASTContext , const CXXMethodDecl *MD) {
-  auto DefaultCC = C.getDefaultCallingConvention(/*IsVariadic=*/false,
- /*IsCSSMethod=*/true);
-  auto CC = MD->getType()->getAs()->getCallConv();
-  return CC == DefaultCC;
-};
-
-if (const auto *CD = dyn_cast_or_null(ND)) {
-  Manglings.emplace_back(getMangledStructor(CD, Ctor_Base));
-
-  if (Ctx.getTargetInfo().getCXXABI().isItaniumFamily())
-if (!CD->getParent()->isAbstract())
-  Manglings.emplace_back(getMangledStructor(CD, Ctor_Complete));
-
-  if (Ctx.getTargetInfo().getCXXABI().isMicrosoft())
-if (CD->hasAttr() && CD->isDefaultConstructor())
-  if (!(hasDefaultCXXMethodCC(Ctx, CD) && CD->getNumParams() == 0))
-Manglings.emplace_back(getMangledStructor(CD, Ctor_DefaultClosure));
-} else if (const auto *DD = dyn_cast_or_null(ND)) {
-  Manglings.emplace_back(getMangledStructor(DD, Dtor_Base));
-  if (Ctx.getTargetInfo().getCXXABI().isItaniumFamily()) {
-Manglings.emplace_back(getMangledStructor(DD, Dtor_Complete));
-if (DD->isVirtual())
-  Manglings.emplace_back(getMangledStructor(DD, Dtor_Deleting));
-  }
-} else if (const auto *MD = dyn_cast_or_null(ND)) {
-  

[clang-tools-extra] r363761 - [TEST] Fix test on Windows by looking for substrings rather than a regex

2019-06-18 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Tue Jun 18 20:02:33 2019
New Revision: 363761

URL: http://llvm.org/viewvc/llvm-project?rev=363761=rev
Log:
[TEST] Fix test on Windows by looking for substrings rather than a regex
since the escaping of special characters appears to break on Windows.

Modified:
clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp

Modified: clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp?rev=363761=363760=363761=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp Tue Jun 18 20:02:33 
2019
@@ -239,10 +239,13 @@ TEST(TweakTest, DumpAST) {
   checkNotAvailable(ID, "/*c^omment*/ int foo() return 2 ^ + 2; }");
 
   const char *Input = "int x = 2 ^+ 2;";
-  const char *Output = R"(BinaryOperator.*'\+'.*
-.*IntegerLiteral.*'int' 2.*
-.*IntegerLiteral.*'int' 2.*)";
-  EXPECT_THAT(getMessage(ID, Input), ::testing::MatchesRegex(Output));
+  auto result = getMessage(ID, Input);
+  EXPECT_THAT(result, ::testing::HasSubstr("BinaryOperator"));
+  EXPECT_THAT(result, ::testing::HasSubstr("'+'"));
+  EXPECT_THAT(result, ::testing::HasSubstr("|-IntegerLiteral"));
+  EXPECT_THAT(result,
+  ::testing::HasSubstr(" 'int' 2\n`-IntegerLiteral"));
+  EXPECT_THAT(result, ::testing::HasSubstr(" 'int' 2"));
 }
 
 TEST(TweakTest, ShowSelectionTree) {


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


[PATCH] D62888: [NewPM] Port Sancov

2019-06-18 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1231-1232
+  MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+  MPM.addPass(
+  
createModuleToFunctionPassAdaptor(SanitizerCoveragePass(SancovOpts)));
+}

leonardchan wrote:
> chandlerc wrote:
> > Is there an existing function pass pipeline we can put this in, maybe by 
> > using an extension point? That would make it much faster to run I suspect.
> I tried this earlier, but when I use `registerOptimizerLastEPCallback()` 
> before the default module pipeline is made, I end up getting this linker 
> error for `-O2` runs:
> 
> ```
> fuzzer.c:(.text.sancov.module_ctor_8bit_counters[sancov.module_ctor_8bit_counters]+0x11):
>  undefined reference to `__start___sancov_pcs'
> fuzzer.c:(.text.sancov.module_ctor_8bit_counters[sancov.module_ctor_8bit_counters]+0x16):
>  undefined reference to `__stop___sancov_pcs'
> ```
> 
> I don't understand how I get this because the symbols are declared in the IR 
> dump as:
> 
> ```
> @__start___sancov_pcs = external hidden global i64*
> @__stop___sancov_pcs = external hidden global i64*
> ```
> 
> for both the optimized cases if I use the adaptor or EP. I'm still linking 
> with the same compiler-rt in each case.
> 
> The only difference I think of using the adaptor after 
> `buildPerModuleDefaultPipeline()` vs using the extension point callback 
> before is that the order in which the pass will be called changes, although I 
> still don't see how it could lead to this undefined reference if I still link 
> against compiler-rt.
> 
> Additionally, the only difference between the IR between using the adaptor vs 
> the EP is a few extra globals/declarations seem to be missing when using the 
> EP, which makes me think another pass that ran after this one removed them, 
> although these don't seem to be related to the error.
> 
Hmm...

Maybe those missing globals / declarations are relevant. Maybe they are 
necessary to get the linking against the sancov runtime to work correctly?

You could try adding these globals / declarations to the 'used' set so they 
don't get removed by later passes:
https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable

Otherwise, I have no idea, maybe makes sense to loop in the sanitizer folks 
explicitly for help debugging this...



Comment at: llvm/lib/Passes/PassRegistry.def:248
 FUNCTION_PASS("tsan", ThreadSanitizerPass())
+FUNCTION_PASS("sancov-func", SanitizerCoveragePass())
 #undef FUNCTION_PASS

leonardchan wrote:
> chandlerc wrote:
> > Consistency would suggest just `sancov` here? I don't feel strongly though.
> Ah, so the reason why I don't use `sancov` here is because in the tests when 
> using `-passes='function(sancov)', I get the following error:
> 
> ```
> /usr/local/google/home/leonardchan/llvm-monorepo/llvm-build-3-b133876586/bin/opt:
>  unknown function pass 
> '/usr/local/google/home/leonardchan/llvm-monorepo/llvm-build-3-b133876586/bin/sancov'
> ```
> 
> I think this is because lit tries to substitute `sancov` with the one under 
> `bin/sancov` in my build dir. I'd be up for changing it if there's a way 
> around this.
That's... really entertaining.

I suspect the tool should really be `llvm-sancov` to avoid this kind of thing.

But anyways, i'm OK with this or calling it something else. There is probably a 
way to hide a thing from `lit`'s substitution as well, I just don't know what 
it is


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62888



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


[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith marked 2 inline comments as done.
rsmith added inline comments.



Comment at: lib/AST/Decl.cpp:3937
+  // -- [has] virtual member functions or virtual base classes, or
+  // -- has subobjects of nonzero size or bit-fields of nonzero length
+  if (const auto *CXXRD = dyn_cast(RD)) {

rjmccall wrote:
> Surely a bit-field of nonzero length is a subobject of nonzero size.
Usually, but not if it's unnamed (unnamed bit-fields aren't subobjects). In any 
case, this is a quote from the C++ standard.



Comment at: lib/AST/Decl.cpp:3945
+return false;
+  }
+

rjmccall wrote:
> Is this a C/C++ modules interaction?
We don't allow C modules to be imported into C++ compilations or vice versa, so 
this should be unreachable unless we start allowing the attribute in C. Nice 
catch.

I guess the question is, then: should we allow this attribute in C (either with 
a GNU `__attribute__` spelling or as a C20 `[[clang::attribute]]`)? I don't 
think it's really useful in C (empty structs are ill-formed, and you can't 
reuse tail padding because structs are always trivial, at least in standard C), 
so I'm inclined to say no.



Comment at: lib/CodeGen/CGExprAgg.cpp:1850
+AggValueSlot::Overlap_t
+CodeGenFunction::overlapForFieldInit(const FieldDecl *FD) {
+  if (!FD->hasAttr() || !FD->getType()->isRecordType())

rjmccall wrote:
> `getOverlapForFieldInit`?  `overlap` is a verb.
Good idea. (Both this and `overlapForBaseInit` are pre-existing; I'll rename 
both.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451



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


[PATCH] D62225: [clang][NewPM] Fixing remaining -O0 tests that are broken under new PM

2019-06-18 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

FWIW, this LGTM. We may want to tweak the behavior around flattening, but that 
can happen as a follow-up, and this seems to get us to a better state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62225



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-18 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

OMG, I'm so sorry, I had no idea that the tests would explode like that... 
Yeah, I don't think that's useful

Maybe a better approach is to just explicitly run the code through `opt 
-passes=instsimplify` before handing it to FileCheck? That should produce 
almost identical results to the old PM's inliner?

Feel free to just try this out and report back -- if it isn't looking good, 
don't invest a bunch of time in it, we should talk to Craig and figure out what 
the right long-term strategy here is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D62688: [Analyzer] Iterator Checkers - Model `empty()` method of containers

2019-06-18 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1741-1763
+bool isContainer(const CXXRecordDecl *CRD) {
+  if (!CRD)
+return false;
+
+  for (const auto *Decl : CRD->decls()) {
+const auto *TD = dyn_cast(Decl);
+if (!TD)

But what if we have a container for which the iterator isn't an inline class, 
or we don't even have an in-class alias for it? I think whether the record has 
a `begin`/`end` method would be a better heuristic.



Comment at: test/Analysis/iterator-range.cpp:247
+void empty(const std::vector ) {
+  for (auto n: V) {}
+  *V.begin(); // expected-warning{{Past-the-end iterator dereferenced}}

Aha, the for loop is here to force a state split on whether `V` is empty or 
not, correct?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62688



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


[PATCH] D63156: [clang][NewPM] Add -fno-experimental-new-pass-manager to tests

2019-06-18 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

In D63156#1543937 , @leonardchan wrote:

> I did some more digging and found the following differences between PMs for 
> each test, and they seem to all differ and can be fixed for different reasons.


Awesome, and sorry this is such a big effort, but I think these are all going 
to end up being pretty interesting root causes. I guess yay, Clang's testing is 
doing its job?

> **CodeGen/aggregate-assign-call.c**: The new PM on -O1 codegen produces the 
> do/while loop differently but still emits the lifetime start/end intrinsics 
> around temporary variables, which is what the test checks for. Here we can 
> just check for the instructions while ignoring the branches generated.

Weird, but makes sense.

> **CodeGen/arm_acle.c**: A bunch of instructions seem to have been combined 
> into a call to `llvm.fshl.i32`, so we just check for those under the new PM.

Same.

> **CodeGen/available-externally-suppress.c**: `available_externally` was not 
> emitted during `-O2 -flto` runs when it should still be retained for link 
> time inlining purposes. This can be fixed by checking that we aren't 
> LTOPrelinking when adding the `EliminateAvailableExternallyPass`.

Yikes, this is a good bug to fix!

> **CodeGen/pgo-sample.c [No new fix]**: The test checks that `PruneEH` runs, 
> but there doesn’t seem to be a corresponding new PM pass for it. Should there 
> be? If there is one then we can just check for that in the debug PM dump.

The analog would be `function-attrs` and `function(simplify-cfg)` in some 
combination. Maybe this should just check that some specific thing is optimized 
away at `-O2` rather than checking the specific details of pass pipeline 
construction?

> **CodeGen/x86_64-instrument-functions.c [No new fix]**: This one's a bit 
> complicated. The initial problem seems to be that `EntryExitInstrumenterPass` 
> was not added into the pipeline to emit `__cyg_profile_func_enter/exit()` 
> calls. Adding that to the pipeline seems to instrument correctly now and add 
> these calls, but we run into a problem with inlining. `root()` expects 2 
> calls to `__cyg_profile_func_enter` and 2 calls to `__cyg_profile_func_exit` 
> in its body,
> 
>   ; Function Attrs: nounwind
>   define i32 @root(i32 returned %x) #0 {
>   entry:
> %0 = tail call i8* @llvm.returnaddress(i32 0)
> tail call void @__cyg_profile_func_enter(i8* bitcast (i32 (i32)* @root to 
> i8*), i8* %0) #2
> tail call void @__cyg_profile_func_enter(i8* bitcast (i32 (i32)* @leaf to 
> i8*), i8* %0) #2
> tail call void @__cyg_profile_func_exit(i8* bitcast (i32 (i32)* @leaf to 
> i8*), i8* %0) #2
> tail call void @__cyg_profile_func_exit(i8* bitcast (i32 (i32)* @root to 
> i8*), i8* %0) #2
> ret i32 %x
>   }
> 
> 
> but we get only 1 call
> 
>   ; Function Attrs: norecurse nounwind readnone
>   define i32 @root(i32 returned %x) local_unnamed_addr #0 {
>   entry:
> %0 = call i8* @llvm.returnaddress(i32 0)
> call void @__cyg_profile_func_enter(i8* bitcast (i32 (i32)* @root to 
> i8*), i8* %0)
> %1 = call i8* @llvm.returnaddress(i32 0)
> call void @__cyg_profile_func_exit(i8* bitcast (i32 (i32)* @root to i8*), 
> i8* %1)
> ret i32 %x
>   }
> 
> 
> I suspect this is due to the `leaf()` being inlined into `root()` even though 
> inlining should happen after it. The legacy `EntryExitInstrumenter` pass 
> seems to be added to the legacy FunctionPassManager first before all others 
> passes. Under the legacy PM, when this pass runs, `root()` should look like:
> 
>   ; Function Attrs: nounwind
>   define i32 @root(i32 %x) #1 {
>   entry:
> %x.addr = alloca i32, align 4
> store i32 %x, i32* %x.addr, align 4, !tbaa !2
> %0 = load i32, i32* %x.addr, align 4, !tbaa !2
> %call = call i32 @leaf(i32 %0)  ; this call is not yet inlined
> ret i32 %call
>   }
> 
> 
> but `root()` looks like this in the new PM pass:
> 
>   ; Function Attrs: norecurse nounwind readnone
>   define i32 @root(i32 returned %x) local_unnamed_addr #1 {
>   entry:
> ret i32 %x
>   }

Yeah, I think the entry/exit pass really wants to come *before* any other pass. 
That should be possible even in the new PM by using an extension point?

> **CodeGenCXX/auto-var-init.cpp**: Auto var initialization is performed 
> differently under new PM than legacy. With initialization for structs with 
> default values, the legacy PM will store the stream of 0xAAs, then initialize 
> the members with default values in a constructor, whereas the new PM will 
> just store the correct value for the whole struct right away without 
> initialization. In one case, it seems that ctor function was also inlined. 
> Fixed by check accounting for these checks separately.

Cool, makes sense.

> **CodeGenCXX/conditional-temporaries.cpp**: The new pm seems to be unable to 
> statically determine the return value of some functions. For now I just add 
> separate checks for the new PM IR.


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-18 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

OK so I instead wrote a script that generated the tests for me since changing 
each individual case by hand was painful. All the `-cc1` tests now match, 
although I don't know any ways of simplifying the IR further to help reduce 
test size. I would definitely love to know if there are any ways to simplify 
the instructions. Unfortunately for `convergent.cl`, the codegen still differs 
slightly around the end of the loop when using `-instcombine` in addition to 
`instnamer`:

  < for.body: ; preds = %for.body, 
%entry
  <   %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  ---
  > for.body: ; preds = 
%for.body.for.body_crit_edge, %entry
  >   %inc.phi = phi i32 [ 1, %entry ], [ %inc.1, %for.body.for.body_crit_edge ]
  92,94c92,97
  <   %inc = add nuw nsw i32 %i.03, 1
  <   %cmp = icmp ult i32 %inc, 10
  <   br i1 %cmp, label %for.body, label %for.cond.cleanup
  ---
  >   %cmp = icmp ult i32 %inc.phi, 10
  >   br i1 %cmp, label %for.body.for.body_crit_edge, label %for.cond.cleanup
  > 
  > for.body.for.body_crit_edge:  ; preds = %for.body
  >   %inc.1 = add nuw nsw i32 %inc.phi, 1
  >   br label %for.body

Also adding @craig.topper in case he as any insight on the updated tests.




Comment at: clang/test/CodeGenOpenCL/convergent.cl:2
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fno-experimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fexperimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s --check-prefixes=CHECK,CHECK-NEWPM
 

chandlerc wrote:
> Probably want to use `opt -passes=instnamer` or some such to use the new PM 
> in the `opt` invocation as well...
Unfortunately there doesn't seem to be a new PM equivalent for `instnamer` (but 
one does exist for `instcombine`). For simplicity, should we stick with using 
the legacy driver for now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-18 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 205496.
leonardchan marked an inline comment as done.
leonardchan added a reviewer: craig.topper.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174

Files:
  clang/test/CodeGen/avx512-reduceMinMaxIntrin.c
  clang/test/CodeGen/avx512f-builtins.c
  clang/test/CodeGen/avx512vl-builtins.c
  clang/test/CodeGen/avx512vlbw-builtins.c
  clang/test/CodeGenOpenCL/convergent.cl



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


[PATCH] D62571: Implement codegen for MSVC unions with reference members

2019-06-18 Thread Dominic Ferreira via Phabricator via cfe-commits
domdom updated this revision to Diff 205495.
domdom added a comment.

clang-formatted the test.


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

https://reviews.llvm.org/D62571

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGenCXX/ms-union-member-ref.cpp


Index: clang/test/CodeGenCXX/ms-union-member-ref.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ms-union-member-ref.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fms-extensions %s -emit-llvm -o- | FileCheck %s
+
+union A {
+  int *
+  int **ptr;
+};
+
+int *f1(A *a) {
+  return a->ref;
+}
+// CHECK-LABEL: define {{.*}}i32* @_Z2f1P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   ret i32* [[IP]]
+
+void f2(A *a) {
+  *a->ref = 1;
+}
+// CHECK-LABEL: define {{.*}}void @_Z2f2P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   store i32 1, i32* [[IP]]
+
+bool f3(A *a, int *b) {
+  return a->ref != b;
+}
+// CHECK-LABEL: define {{.*}}i1 @_Z2f3P1APi(%union.A* %a, i32* %b)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   [[IP2:%[^[:space:]]+]]  = load i32*, i32** %b.addr
+// CHECK:   icmp ne i32* [[IP]], [[IP2]]
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3929,29 +3929,32 @@
   unsigned RecordCVR = base.getVRQualifiers();
   if (rec->isUnion()) {
 // For unions, there is no pointer adjustment.
-assert(!FieldType->isReferenceType() && "union has reference member");
 if (CGM.getCodeGenOpts().StrictVTablePointers &&
 hasAnyVptr(FieldType, getContext()))
   // Because unions can easily skip invariant.barriers, we need to add
   // a barrier every time CXXRecord field with vptr is referenced.
   addr = Address(Builder.CreateLaunderInvariantGroup(addr.getPointer()),
  addr.getAlignment());
+
+if (FieldType->isReferenceType())
+  addr = Builder.CreateElementBitCast(
+  addr, CGM.getTypes().ConvertTypeForMem(FieldType), field->getName());
   } else {
 // For structs, we GEP to the field that the record layout suggests.
 addr = emitAddrOfFieldStorage(*this, addr, field);
+  }
 
-// If this is a reference field, load the reference right now.
-if (FieldType->isReferenceType()) {
-  LValue RefLVal = MakeAddrLValue(addr, FieldType, FieldBaseInfo,
-  FieldTBAAInfo);
-  if (RecordCVR & Qualifiers::Volatile)
-RefLVal.getQuals().addVolatile();
-  addr = EmitLoadOfReference(RefLVal, , );
-
-  // Qualifiers on the struct don't apply to the referencee.
-  RecordCVR = 0;
-  FieldType = FieldType->getPointeeType();
-}
+  // If this is a reference field, load the reference right now.
+  if (FieldType->isReferenceType()) {
+LValue RefLVal = MakeAddrLValue(addr, FieldType, FieldBaseInfo,
+FieldTBAAInfo);
+if (RecordCVR & Qualifiers::Volatile)
+  RefLVal.getQuals().addVolatile();
+addr = EmitLoadOfReference(RefLVal, , );
+
+// Qualifiers on the struct don't apply to the referencee.
+RecordCVR = 0;
+FieldType = FieldType->getPointeeType();
   }
 
   // Make sure that the address is pointing to the right type.  This is 
critical


Index: clang/test/CodeGenCXX/ms-union-member-ref.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ms-union-member-ref.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fms-extensions %s -emit-llvm -o- | FileCheck %s
+
+union A {
+  int *
+  int **ptr;
+};
+
+int *f1(A *a) {
+  return a->ref;
+}
+// CHECK-LABEL: define {{.*}}i32* @_Z2f1P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   ret i32* [[IP]]
+
+void f2(A *a) {
+  *a->ref = 1;
+}
+// CHECK-LABEL: define {{.*}}void @_Z2f2P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   store i32 1, i32* [[IP]]
+
+bool f3(A *a, int *b) {
+  return a->ref != b;
+}
+// CHECK-LABEL: define {{.*}}i1 

[PATCH] D62688: [Analyzer] Iterator Checkers - Model `empty()` method of containers

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

Hmm, an idea just popped into my head. I'm not sure whether we have a single 
checker that does so much complicated (and totally awesome) modeling as 
`IteratorChecker`.  What do you think about a debug checker similar to 
`debug.ExprInspection`, like `debug.IteratorInspection`?

  // RUN: %clang_analyzer_cc1 -analyzer-checker=core,debug.IteratorInspection
  
  template 
  void clang_analyzer_container_size(const Cont &);
  
  template 
  void clang_analyzer_is_attached_to_container(const It &, const Cont &);
  
  void non_empty1(const std::vector ) {
assert(!V.empty());
for (auto n: V) {}
clang_analyzer_container_size(V); // expected-warning{{[1, intmax]}}
  }
  
  void non_empty2(const std::vector ) {
for (auto n: V) {}
assert(V.empty());
clang_analyzer_container_size(V); // expected-warning{{[0, 0]}}
  }
  
  void foo(std::vector v1, std::vector v2) {
clang_analyzer_is_attached_to_container(v1.begin(), v2); // 
expected-warning{{FALSE}}
  }

etc etc.




Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:714
 
 if (const auto *InstCall = dyn_cast()) {
   if (isBeginCall(Func)) {

We seem to retrieve the `CXXInstanceCall` here too?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62688



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


[PATCH] D62915: git-clang-format: Remove trailing whitespace in docstring. NFC.

2019-06-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363759: git-clang-format: Remove trailing whitespace in 
docstring. NFC. (authored by sbc, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62915?vs=203181=205494#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62915

Files:
  cfe/trunk/tools/clang-format/git-clang-format


Index: cfe/trunk/tools/clang-format/git-clang-format
===
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -8,19 +8,19 @@
 #
 
#======#
 
-r"""   
  
-clang-format git integration   
  
-   
  
-   
  
-This file provides a clang-format integration for git. Put it somewhere in 
your  
-path and ensure that it is executable. Then, "git clang-format" will invoke
  
-clang-format on the changes in current files or a specific commit. 
  
-   
  
-For further details, run:  
  
-git clang-format -h
  
-   
  
-Requires Python 2.7 or Python 3
  
-"""   
+r"""
+clang-format git integration
+
+
+This file provides a clang-format integration for git. Put it somewhere in your
+path and ensure that it is executable. Then, "git clang-format" will invoke
+clang-format on the changes in current files or a specific commit.
+
+For further details, run:
+git clang-format -h
+
+Requires Python 2.7 or Python 3
+"""
 
 from __future__ import absolute_import, division, print_function
 import argparse


Index: cfe/trunk/tools/clang-format/git-clang-format
===
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -8,19 +8,19 @@
 #
 #======#
 
-r""" 
-clang-format git integration 
- 
- 
-This file provides a clang-format integration for git. Put it somewhere in your  
-path and ensure that it is executable. Then, "git clang-format" will invoke  
-clang-format on the changes in current files or a specific commit.   
- 
-For further details, run:
-git clang-format -h  
- 
-Requires Python 2.7 or Python 3  
-"""   
+r"""
+clang-format git integration
+
+
+This file provides a clang-format integration for git. Put it somewhere in your
+path and ensure that it is executable. Then, "git clang-format" will invoke
+clang-format on the changes in current files or a specific commit.
+
+For further details, run:
+git clang-format -h
+
+Requires Python 2.7 or Python 3
+"""
 
 from __future__ import absolute_import, division, print_function
 import argparse
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r363760 - Fix more tests after r363749

2019-06-18 Thread Aaron Puchert via cfe-commits
Author: aaronpuchert
Date: Tue Jun 18 18:54:05 2019
New Revision: 363760

URL: http://llvm.org/viewvc/llvm-project?rev=363760=rev
Log:
Fix more tests after r363749

Apparently -Wmissing-prototypes is used for quite a few integration
tests.

Modified:
clang-tools-extra/trunk/test/clang-tidy/export-diagnostics.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/export-diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/export-diagnostics.cpp?rev=363760=363759=363760=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/export-diagnostics.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/export-diagnostics.cpp Tue Jun 18 
18:54:05 2019
@@ -8,6 +8,8 @@ X(f)
 // CHECK-MESSAGES: -input.cpp:2:1: warning: no previous prototype for function 
'ff' [clang-diagnostic-missing-prototypes]
 // CHECK-MESSAGES: -input.cpp:1:19: note: expanded from macro 'X'
 // CHECK-MESSAGES: {{^}}note: expanded from here{{$}}
+// CHECK-MESSAGES: -input.cpp:2:1: note: declare 'static' if the function is 
not intended to be used outside of this translation unit
+// CHECK-MESSAGES: -input.cpp:1:14: note: expanded from macro 'X'
 
 // CHECK-YAML: ---
 // CHECK-YAML-NEXT: MainSourceFile:  '{{.*}}-input.cpp'
@@ -28,4 +30,16 @@ X(f)
 // CHECK-YAML-NEXT: FilePath:''
 // CHECK-YAML-NEXT: FileOffset:  0
 // CHECK-YAML-NEXT: Replacements:[]
+// CHECK-YAML-NEXT:   - Message: 'declare ''static'' if the 
function is not intended to be used outside of this translation unit'
+// CHECK-YAML-NEXT: FilePath:'{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: FileOffset:  30
+// CHECK-YAML-NEXT: Replacements:
+// CHECK-YAML-NEXT:   - FilePath:'{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: Offset:  30
+// CHECK-YAML-NEXT: Length:  0
+// CHECK-YAML-NEXT: ReplacementText: 'static '
+// CHECK-YAML-NEXT:   - Message: 'expanded from macro ''X'''
+// CHECK-YAML-NEXT: FilePath:'{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: FileOffset:  13
+// CHECK-YAML-NEXT: Replacements:[]
 // CHECK-YAML-NEXT: ...


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


r363759 - git-clang-format: Remove trailing whitespace in docstring. NFC.

2019-06-18 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Tue Jun 18 18:52:41 2019
New Revision: 363759

URL: http://llvm.org/viewvc/llvm-project?rev=363759=rev
Log:
git-clang-format: Remove trailing whitespace in docstring. NFC.

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

Modified:
cfe/trunk/tools/clang-format/git-clang-format

Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=363759=363758=363759=diff
==
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ cfe/trunk/tools/clang-format/git-clang-format Tue Jun 18 18:52:41 2019
@@ -8,19 +8,19 @@
 #
 
#======#
 
-r"""   
  
-clang-format git integration   
  
-   
  
-   
  
-This file provides a clang-format integration for git. Put it somewhere in 
your  
-path and ensure that it is executable. Then, "git clang-format" will invoke
  
-clang-format on the changes in current files or a specific commit. 
  
-   
  
-For further details, run:  
  
-git clang-format -h
  
-   
  
-Requires Python 2.7 or Python 3
  
-"""   
+r"""
+clang-format git integration
+
+
+This file provides a clang-format integration for git. Put it somewhere in your
+path and ensure that it is executable. Then, "git clang-format" will invoke
+clang-format on the changes in current files or a specific commit.
+
+For further details, run:
+git clang-format -h
+
+Requires Python 2.7 or Python 3
+"""
 
 from __future__ import absolute_import, division, print_function
 import argparse


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


[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Can this attribute not be applied to a base class, or to a type?  I think every 
time I've seen someone get bitten by the unique-address rule, it was because 
they had a base class that deleted some constructors (or something like that) 
and which was a base of a million different types; I'm sure the language model 
they'd prefer would be to just add an attribute to that one type instead of 
chasing down every place where they declared a field of the type.




Comment at: include/clang/Basic/Attr.td:345
+  let CXXABIs = ["GenericItanium", "GenericARM", "iOS", "iOS64", "WatchOS",
+ "GenericAArch64", "GenericMIPS", "WebAssembly"];
+}

Can you just duplicate the thing that Slava Pestov recently did for LangOpts?  
The tblgen enhancement really isn't very complicated, and I think we can agree 
that this is terrible. :)

We can probably kill the need for `CXXABIs` in tblgen entirely.



Comment at: include/clang/Basic/AttrDocs.td:1020
+point within the class (except that it does not share a vptr with the enclosing
+object).
+  }];

Can you include an example here?  And should this documentation mention that 
this is a standard C++ attribute (or at least one proposed for adoption)?



Comment at: lib/AST/Decl.cpp:3937
+  // -- [has] virtual member functions or virtual base classes, or
+  // -- has subobjects of nonzero size or bit-fields of nonzero length
+  if (const auto *CXXRD = dyn_cast(RD)) {

Surely a bit-field of nonzero length is a subobject of nonzero size.



Comment at: lib/AST/Decl.cpp:3945
+return false;
+  }
+

Is this a C/C++ modules interaction?



Comment at: lib/CodeGen/CGExprAgg.cpp:1850
+AggValueSlot::Overlap_t
+CodeGenFunction::overlapForFieldInit(const FieldDecl *FD) {
+  if (!FD->hasAttr() || !FD->getType()->isRecordType())

`getOverlapForFieldInit`?  `overlap` is a verb.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451



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


[PATCH] D62738: [HIP] Support device_shadow variable

2019-06-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 205490.
yaxunl retitled this revision from "[HIP] Support texture type" to "[HIP] 
Support device_shadow variable".
yaxunl edited the summary of this revision.
yaxunl added a comment.

Revised by Artem's comments.


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

https://reviews.llvm.org/D62738

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/AST/ast-dump-cuda-device-shadow.cu
  test/CodeGenCUDA/device-shadow.cu
  test/Misc/pragma-attribute-supported-attributes-list.test

Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -26,6 +26,7 @@
 // CHECK-NEXT: CPUSpecific (SubjectMatchRule_function)
 // CHECK-NEXT: CUDAConstant (SubjectMatchRule_variable)
 // CHECK-NEXT: CUDADevice (SubjectMatchRule_function, SubjectMatchRule_variable)
+// CHECK-NEXT: CUDADeviceShadow (SubjectMatchRule_variable)
 // CHECK-NEXT: CUDAGlobal (SubjectMatchRule_function)
 // CHECK-NEXT: CUDAHost (SubjectMatchRule_function)
 // CHECK-NEXT: CUDALaunchBounds (SubjectMatchRule_objc_method, SubjectMatchRule_hasType_functionType)
Index: test/CodeGenCUDA/device-shadow.cu
===
--- /dev/null
+++ test/CodeGenCUDA/device-shadow.cu
@@ -0,0 +1,28 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -std=c++11 -fcuda-is-device \
+// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CUDADEV %s
+// RUN: %clang_cc1 -triple x86_64 -std=c++11 \
+// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CUDAHOST %s
+
+// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -std=c++11 -fvisibility hidden -fapply-global-visibility-to-externs \
+// RUN: -emit-llvm -o - -x hip %s | FileCheck -check-prefixes=HIPDEV %s
+// RUN: %clang_cc1 -triple x86_64 -std=c++11 \
+// RUN: -emit-llvm -o - -x hip %s | FileCheck -check-prefixes=HIPHOST %s
+
+struct textureReference {
+  int a;
+};
+
+template 
+struct texture : public textureReference {
+texture() { a = 1; }
+};
+
+__attribute__((device_shadow)) texture tex;
+// CUDADEV-NOT: @tex
+// CUDAHOST-NOT: call i32 @__hipRegisterVar{{.*}}@tex
+// HIPDEV: @tex = external protected{{.*}}global %struct.texture
+// HIPDEV-NOT: declare{{.*}}void @_ZN7textureIfLi2ELi1EEC1Ev
+// HIPHOST:  define{{.*}}@_ZN7textureIfLi2ELi1EEC1Ev
+// HIPHOST:  call i32 @__hipRegisterVar{{.*}}@tex{{.*}}i32 0, i32 4, i32 0, i32 0)
Index: test/AST/ast-dump-cuda-device-shadow.cu
===
--- /dev/null
+++ test/AST/ast-dump-cuda-device-shadow.cu
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fcuda-is-device -ast-dump -ast-dump-filter tex %s | FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -ast-dump -ast-dump-filter tex %s | FileCheck -strict-whitespace %s
+struct textureReference {
+  int a;
+};
+
+// CHECK: CUDADeviceShadowAttr
+template 
+struct texture : public textureReference {
+texture() { a = 1; }
+};
+
+__attribute__((device_shadow)) texture tex;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6786,6 +6786,10 @@
   case ParsedAttr::AT_CUDAHost:
 handleSimpleAttributeWithExclusions(S, D, AL);
 break;
+  case ParsedAttr::AT_CUDADeviceShadow:
+handleSimpleAttributeWithExclusions(
+S, D, AL);
+break;
   case ParsedAttr::AT_GNUInline:
 handleGNUInlineAttr(S, D, AL);
 break;
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7848,7 +7848,8 @@
   return D->hasAttr() ||
  (isa(D) && D->hasAttr()) ||
  (isa(D) &&
-  (D->hasAttr() || D->hasAttr()));
+  (D->hasAttr() || D->hasAttr() ||
+   D->hasAttr()));
 }
 
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2414,7 +2414,8 @@
   if (!Global->hasAttr() &&
   !Global->hasAttr() &&
   !Global->hasAttr() &&
-  !Global->hasAttr())
+  !Global->hasAttr() &&
+  !(LangOpts.HIP && Global->hasAttr()))
 return;
 } else {
   // We need to emit host-side 'shadows' for all global
@@ -3769,7 +3770,12 @@
   !getLangOpts().CUDAIsDevice &&
   (D->hasAttr() || D->hasAttr() ||
D->hasAttr());
-  if (getLangOpts().CUDA && (IsCUDASharedVar || IsCUDAShadowVar))
+  // Device side shadow of initialized host-side global variables are also

[PATCH] D63508: make -frewrite-includes handle __has_include wrapped in a macro

2019-06-18 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Luboš, can you please clarify what is wrong with the current Clang behavior? 
I'm just thinking about what should we do with nested macros.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63508



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


[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 205488.
rsmith added a comment.

- Remove accidentally-added file


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclCXX.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/AST/Decl.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGRecordLayoutBuilder.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/no-unique-address.cpp
  test/CodeGenCXX/tail-padding.cpp
  test/Layout/no-unique-address.cpp
  test/SemaCXX/cxx2a-no-unique-address.cpp
  utils/TableGen/ClangAttrEmitter.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -934,7 +934,7 @@
 
   [[no_unique_address]] attribute
   http://wg21.link/p0840r2;>P0840R2
-  No
+  SVN
 
 
   [[likely]] and [[unlikely]] attributes
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2810,7 +2810,7 @@
 
 // Helper function for GenerateTargetSpecificAttrChecks that alters the 'Test'
 // parameter with only a single check type, if applicable.
-static void GenerateTargetSpecificAttrCheck(const Record *R, std::string ,
+static bool GenerateTargetSpecificAttrCheck(const Record *R, std::string ,
 std::string *FnName,
 StringRef ListName,
 StringRef CheckAgainst,
@@ -2830,7 +2830,9 @@
 *FnName += Part;
 }
 Test += ")";
+return true;
   }
+  return false;
 }
 
 // Generate a conditional expression to check if the current target satisfies
@@ -2838,10 +2840,12 @@
 // those checks to the Test string. If the FnName string pointer is non-null,
 // append a unique suffix to distinguish this set of target checks from other
 // TargetSpecificAttr records.
-static void GenerateTargetSpecificAttrChecks(const Record *R,
+static bool GenerateTargetSpecificAttrChecks(const Record *R,
  std::vector ,
  std::string ,
  std::string *FnName) {
+  bool AnyTargetChecks = false;
+
   // It is assumed that there will be an llvm::Triple object
   // named "T" and a TargetInfo object named "Target" within
   // scope that can be used to determine whether the attribute exists in
@@ -2851,6 +2855,7 @@
   // differently because GenerateTargetRequirements needs to combine the list
   // with ParseKind.
   if (!Arches.empty()) {
+AnyTargetChecks = true;
 Test += " && (";
 for (auto I = Arches.begin(), E = Arches.end(); I != E; ++I) {
   StringRef Part = *I;
@@ -2865,16 +2870,19 @@
   }
 
   // If the attribute is specific to particular OSes, check those.
-  GenerateTargetSpecificAttrCheck(R, Test, FnName, "OSes", "T.getOS()",
-  "llvm::Triple::");
+  AnyTargetChecks |= GenerateTargetSpecificAttrCheck(
+  R, Test, FnName, "OSes", "T.getOS()", "llvm::Triple::");
 
   // If one or more CXX ABIs are specified, check those as well.
   GenerateTargetSpecificAttrCheck(R, Test, FnName, "CXXABIs",
   "Target.getCXXABI().getKind()",
   "TargetCXXABI::");
   // If one or more object formats is specified, check those.
-  GenerateTargetSpecificAttrCheck(R, Test, FnName, "ObjectFormats",
-  "T.getObjectFormat()", "llvm::Triple::");
+  AnyTargetChecks |=
+  GenerateTargetSpecificAttrCheck(R, Test, FnName, "ObjectFormats",
+  "T.getObjectFormat()", "llvm::Triple::");
+
+  return AnyTargetChecks;
 }
 
 static void GenerateHasAttrSpellingStringSwitch(
@@ -3510,7 +3518,7 @@
 
   std::string FnName = "isTarget";
   std::string Test;
-  GenerateTargetSpecificAttrChecks(R, Arches, Test, );
+  bool UsesT = GenerateTargetSpecificAttrChecks(R, Arches, Test, );
 
   // If this code has already been generated, simply return the previous
   // instance of it.
@@ -3520,7 +3528,8 @@
 return *I;
 
   OS << "static bool " << FnName << "(const TargetInfo ) {\n";
-  OS << "  const llvm::Triple  = Target.getTriple();\n";
+  if (UsesT)
+OS << "  const llvm::Triple  = Target.getTriple();\n";
   OS << "  return " << Test << ";\n";
   OS << "}\n\n";
 
Index: test/SemaCXX/cxx2a-no-unique-address.cpp
===
--- /dev/null
+++ 

[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/DeclCXX.h:337-341
 /// true when this class is empty for traits purposes,
-/// i.e. has no data members other than 0-width bit-fields, has no
+/// i.e. has no data members other than 0-width bit-fields and empty
+/// fields marked [[no_unique_address]], has no
 /// virtual function/base, and doesn't inherit from a non-empty
 /// class. Doesn't take union-ness into account.

aaron.ballman wrote:
> Do you mind re-flowing this entire comment to 80 cols?
Reflowed and turned into bulleted list for clarity.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451



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


[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 205487.
rsmith marked 5 inline comments as done.
rsmith added a comment.
Herald added a reviewer: jfb.
Herald added subscribers: jfb, arphaman.

- Address review comments from @AaronBallman.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclCXX.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/AST/Decl.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGRecordLayoutBuilder.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/no-unique-address.cpp
  test/CodeGenCXX/tail-padding.cpp
  test/Layout/no-unique-address.cpp
  test/SemaCXX/cxx2a-no-unique-address.cpp
  utils/TableGen/ClangAttrEmitter.cpp
  www/cwg_index.html
  www/cxx_status.html



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


[PATCH] D62915: git-clang-format: Remove trailing whitespace in docstring. NFC.

2019-06-18 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added a comment.
This revision is now accepted and ready to land.

I can't find the option of showing whitespace changes in Phabricator so I can't 
see it, but I'm always in favor of removing trailing whitespaces :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62915



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


[PATCH] D63533: [analyzer] Fix clang-tidy crash on GCCAsmStmt

2019-06-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hey, thanks! That's a nice catch.

The code looks fine, but i don't think your test actually tests it - see inline 
comments. Also i think we should put the test into the clang repo (i.e., 
`test/Analysis`), because that's where the change is. I'd like to know it if i 
break your test even if i don't enable clang-tools-extra at all. Because 
clang-tidy isn't available from within the clang sub-project, this would have 
to be implemented as a static analyzer test.




Comment at: clang-tools-extra/test/clang-tidy/asm-goto.cpp:2
+// REQUIRES: static-analyzer
+// RUN: clang-tidy %s -checks='bugprone-use-after-move' -- | FileCheck %s
+#include 

I suspect that the code you modified doesn't get covered by this test unless 
you enable `analyzer-...` checkers.



Comment at: clang-tools-extra/test/clang-tidy/asm-goto.cpp:3-4
+// RUN: clang-tidy %s -checks='bugprone-use-after-move' -- | FileCheck %s
+#include 
+#include 
+int main() {

This is scary because the behavior may depend on the implementation details of 
the standard library that's installed on the current machine. In the Static 
Analyzer we use `test/Analysis/Inputs/system-header-simulator*.h` as a 
mocked-up standard library for testing purposes.



Comment at: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:401
+  case Stmt::GCCAsmStmtClass:
+return;
 }

Please add a TODO to actually implement this functionality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63533



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


LLVM buildmaster will be restarted tonight

2019-06-18 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be restarted after 7PM Pacific time today.

Thanks

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


[PATCH] D63533: [analyzer] Fix clang-tidy crash on GCCAsmStmt

2019-06-18 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry created this revision.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

Added entry in switch statement to recognize GCCAsmStmt
as a possible block terminator.

Handling to build CFG using GCCAsmStmt was already implemented.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63533

Files:
  clang-tools-extra/test/clang-tidy/asm-goto.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp


Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -396,6 +396,9 @@
   case Stmt::WhileStmtClass:
 HandleBranch(cast(Term)->getCond(), Term, B, Pred);
 return;
+
+  case Stmt::GCCAsmStmtClass:
+return;
 }
   }
 
Index: clang-tools-extra/test/clang-tidy/asm-goto.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/asm-goto.cpp
@@ -0,0 +1,29 @@
+// REQUIRES: static-analyzer
+// RUN: clang-tidy %s -checks='bugprone-use-after-move' -- | FileCheck %s
+#include 
+#include 
+int main() {
+struct S {
+  std::string str;
+  int i;
+};
+
+S s = { "Hello, world!\n", 42 };
+S s_other = std::move(s);
+asm goto( "xor %0, %0\n je %l[label1]\n jl %l[label2]" : /* no outputs */ 
: /* inputs */ : /* clobbers */ : label1, label2 /* any labels used */ );
+return 0;
+
+label1:
+// CHECK: warning: 's' used after it was moved [bugprone-use-after-move]
+s.str = "ABC";
+s.i = 99;
+return 2;
+
+label2:
+// There should be a warning here, but UseAfterMoveCheck only reports one
+// warning per std::move
+s.str = "DEF";
+s.i = 100;
+return 0;
+}
+


Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -396,6 +396,9 @@
   case Stmt::WhileStmtClass:
 HandleBranch(cast(Term)->getCond(), Term, B, Pred);
 return;
+
+  case Stmt::GCCAsmStmtClass:
+return;
 }
   }
 
Index: clang-tools-extra/test/clang-tidy/asm-goto.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/asm-goto.cpp
@@ -0,0 +1,29 @@
+// REQUIRES: static-analyzer
+// RUN: clang-tidy %s -checks='bugprone-use-after-move' -- | FileCheck %s
+#include 
+#include 
+int main() {
+struct S {
+  std::string str;
+  int i;
+};
+
+S s = { "Hello, world!\n", 42 };
+S s_other = std::move(s);
+asm goto( "xor %0, %0\n je %l[label1]\n jl %l[label2]" : /* no outputs */ : /* inputs */ : /* clobbers */ : label1, label2 /* any labels used */ );
+return 0;
+
+label1:
+// CHECK: warning: 's' used after it was moved [bugprone-use-after-move]
+s.str = "ABC";
+s.i = 99;
+return 2;
+
+label2:
+// There should be a warning here, but UseAfterMoveCheck only reports one
+// warning per std::move
+s.str = "DEF";
+s.i = 100;
+return 0;
+}
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63369: [AST] Fixed extraneous warnings for binary conditional operator

2019-06-18 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 205473.
Nathan-Huckleberry added a comment.

Mistakenly updated revision. Attempting to revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63369

Files:
  clang/lib/AST/Expr.cpp
  clang/test/Sema/warn-binary-conditional-expression-unused.c


Index: clang/test/Sema/warn-binary-conditional-expression-unused.c
===
--- /dev/null
+++ clang/test/Sema/warn-binary-conditional-expression-unused.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-value -verify %s
+int main() {
+int a;
+int b;
+a ? : b; //expected-warning{{expression result unused}}
+a ? a : b; //expected-warning{{expression result unused}}
+a ? : ++b;
+a ? a : ++b;
+++a ? : b; //expected-warning{{expression result unused}}
+++a ? a : b; //expected-warning{{expression result unused}}
+++a ? : ++b;
+++a ? a : ++b;
+return 0;
+};
+
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2345,12 +2345,13 @@
 // If only one of the LHS or RHS is a warning, the operator might
 // be being used for control flow. Only warn if both the LHS and
 // RHS are warnings.
-const ConditionalOperator *Exp = cast(this);
-if (!Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx))
-  return false;
-if (!Exp->getLHS())
-  return true;
-return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+const auto *Exp = cast(this);
+return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx) &&
+   Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+  }
+  case BinaryConditionalOperatorClass: {
+const auto *Exp = cast(this);
+return Exp->getFalseExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, 
Ctx);
   }
 
   case MemberExprClass:


Index: clang/test/Sema/warn-binary-conditional-expression-unused.c
===
--- /dev/null
+++ clang/test/Sema/warn-binary-conditional-expression-unused.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-value -verify %s
+int main() {
+int a;
+int b;
+a ? : b; //expected-warning{{expression result unused}}
+a ? a : b; //expected-warning{{expression result unused}}
+a ? : ++b;
+a ? a : ++b;
+++a ? : b; //expected-warning{{expression result unused}}
+++a ? a : b; //expected-warning{{expression result unused}}
+++a ? : ++b;
+++a ? a : ++b;
+return 0;
+};
+
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2345,12 +2345,13 @@
 // If only one of the LHS or RHS is a warning, the operator might
 // be being used for control flow. Only warn if both the LHS and
 // RHS are warnings.
-const ConditionalOperator *Exp = cast(this);
-if (!Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx))
-  return false;
-if (!Exp->getLHS())
-  return true;
-return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+const auto *Exp = cast(this);
+return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx) &&
+   Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+  }
+  case BinaryConditionalOperatorClass: {
+const auto *Exp = cast(this);
+return Exp->getFalseExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
   }
 
   case MemberExprClass:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63369: [AST] Fixed extraneous warnings for binary conditional operator

2019-06-18 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 205470.
Nathan-Huckleberry added a comment.

- [analyzer] Fix clang-tidy crash on GCCAsmStmt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63369

Files:
  clang-tools-extra/test/clang-tidy/asm-goto.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/test/Sema/warn-binary-conditional-expression-unused.c


Index: clang/test/Sema/warn-binary-conditional-expression-unused.c
===
--- /dev/null
+++ clang/test/Sema/warn-binary-conditional-expression-unused.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-value -verify %s
+int main() {
+int a;
+int b;
+a ? : b; //expected-warning{{expression result unused}}
+a ? a : b; //expected-warning{{expression result unused}}
+a ? : ++b;
+a ? a : ++b;
+++a ? : b; //expected-warning{{expression result unused}}
+++a ? a : b; //expected-warning{{expression result unused}}
+++a ? : ++b;
+++a ? a : ++b;
+return 0;
+};
+
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -396,6 +396,9 @@
   case Stmt::WhileStmtClass:
 HandleBranch(cast(Term)->getCond(), Term, B, Pred);
 return;
+
+  case Stmt::GCCAsmStmtClass:
+return;
 }
   }
 
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2345,12 +2345,13 @@
 // If only one of the LHS or RHS is a warning, the operator might
 // be being used for control flow. Only warn if both the LHS and
 // RHS are warnings.
-const ConditionalOperator *Exp = cast(this);
-if (!Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx))
-  return false;
-if (!Exp->getLHS())
-  return true;
-return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+const auto *Exp = cast(this);
+return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx) &&
+   Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+  }
+  case BinaryConditionalOperatorClass: {
+const auto *Exp = cast(this);
+return Exp->getFalseExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, 
Ctx);
   }
 
   case MemberExprClass:
Index: clang-tools-extra/test/clang-tidy/asm-goto.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/asm-goto.cpp
@@ -0,0 +1,29 @@
+// REQUIRES: static-analyzer
+// RUN: clang-tidy %s -checks='bugprone-use-after-move' -- | FileCheck %s
+#include 
+#include 
+int main() {
+struct S {
+  std::string str;
+  int i;
+};
+
+S s = { "Hello, world!\n", 42 };
+S s_other = std::move(s);
+asm goto( "xor %0, %0\n je %l[label1]\n jl %l[label2]" : /* no outputs */ 
: /* inputs */ : /* clobbers */ : label1, label2 /* any labels used */ );
+return 0;
+
+label1:
+// CHECK: warning: 's' used after it was moved [bugprone-use-after-move]
+s.str = "ABC";
+s.i = 99;
+return 2;
+
+label2:
+// There should be a warning here, but UseAfterMoveCheck only reports one
+// warning per std::move
+s.str = "DEF";
+s.i = 100;
+return 0;
+}
+


Index: clang/test/Sema/warn-binary-conditional-expression-unused.c
===
--- /dev/null
+++ clang/test/Sema/warn-binary-conditional-expression-unused.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-value -verify %s
+int main() {
+int a;
+int b;
+a ? : b; //expected-warning{{expression result unused}}
+a ? a : b; //expected-warning{{expression result unused}}
+a ? : ++b;
+a ? a : ++b;
+++a ? : b; //expected-warning{{expression result unused}}
+++a ? a : b; //expected-warning{{expression result unused}}
+++a ? : ++b;
+++a ? a : ++b;
+return 0;
+};
+
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -396,6 +396,9 @@
   case Stmt::WhileStmtClass:
 HandleBranch(cast(Term)->getCond(), Term, B, Pred);
 return;
+
+  case Stmt::GCCAsmStmtClass:
+return;
 }
   }
 
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2345,12 +2345,13 @@
 // If only one of the LHS or RHS is a warning, the operator might
 // be being used for control flow. Only warn if both the LHS and
 // RHS are warnings.
-const ConditionalOperator 

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> I'm just laying out the basic requirements for getting this patch back in, 
> because the current patch is invalid given LLVM's current requirements.

Yes, I'm on the same page.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


r363754 - Fix tests after r363749

2019-06-18 Thread Aaron Puchert via cfe-commits
Author: aaronpuchert
Date: Tue Jun 18 16:40:17 2019
New Revision: 363754

URL: http://llvm.org/viewvc/llvm-project?rev=363754=rev
Log:
Fix tests after r363749

We changed -Wmissing-prototypes there, which was used in these tests via
-Weverything.

Modified:
cfe/trunk/test/Preprocessor/Weverything_pragma.c
cfe/trunk/test/Preprocessor/pragma_diagnostic.c
cfe/trunk/test/Preprocessor/pushable-diagnostics.c
cfe/trunk/test/SemaCXX/warn-everthing.cpp

Modified: cfe/trunk/test/Preprocessor/Weverything_pragma.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Weverything_pragma.c?rev=363754=363753=363754=diff
==
--- cfe/trunk/test/Preprocessor/Weverything_pragma.c (original)
+++ cfe/trunk/test/Preprocessor/Weverything_pragma.c Tue Jun 18 16:40:17 2019
@@ -7,6 +7,7 @@
 #define UNUSED_MACRO1 1 // expected-warning{{macro is not used}}
 
 void foo() // expected-warning {{no previous prototype for function}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 {
  // A diagnostic without DefaultIgnore, and not part of a group.
  (void) L'ab'; // expected-warning {{extraneous characters in character 
constant ignored}}

Modified: cfe/trunk/test/Preprocessor/pragma_diagnostic.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pragma_diagnostic.c?rev=363754=363753=363754=diff
==
--- cfe/trunk/test/Preprocessor/pragma_diagnostic.c (original)
+++ cfe/trunk/test/Preprocessor/pragma_diagnostic.c Tue Jun 18 16:40:17 2019
@@ -39,12 +39,15 @@ void ppo(){} // First test that we do no
 
 #pragma clang diagnostic warning "-Weverything"
 void ppp(){} // expected-warning {{no previous prototype for function 'ppp'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 
 #pragma clang diagnostic ignored "-Weverything" // Reset it.
 void ppq(){}
 
 #pragma clang diagnostic error "-Weverything" // Now set to error
 void ppr(){} // expected-error {{no previous prototype for function 'ppr'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 
 #pragma clang diagnostic warning "-Weverything" // This should not be effective
 void pps(){} // expected-error {{no previous prototype for function 'pps'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}

Modified: cfe/trunk/test/Preprocessor/pushable-diagnostics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pushable-diagnostics.c?rev=363754=363753=363754=diff
==
--- cfe/trunk/test/Preprocessor/pushable-diagnostics.c (original)
+++ cfe/trunk/test/Preprocessor/pushable-diagnostics.c Tue Jun 18 16:40:17 2019
@@ -23,17 +23,21 @@ void ppo0(){} // first verify that we do
 
 #pragma clang diagnostic warning "-Weverything" 
 void ppr1(){} // expected-warning {{no previous prototype for function 'ppr1'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 
 #pragma clang diagnostic push // push again
 #pragma clang diagnostic ignored "-Weverything"  // Set to ignore in this 
level.
 void pps2(){}
 #pragma clang diagnostic warning "-Weverything"  // Set to warning in this 
level.
 void ppt2(){} // expected-warning {{no previous prototype for function 'ppt2'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 #pragma clang diagnostic error "-Weverything"  // Set to error in this level.
 void ppt3(){} // expected-error {{no previous prototype for function 'ppt3'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 #pragma clang diagnostic pop // pop should go back to warning level
 
 void pps1(){} // expected-warning {{no previous prototype for function 'pps1'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 
 
 #pragma clang diagnostic pop // Another pop should disble it again

Modified: cfe/trunk/test/SemaCXX/warn-everthing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-everthing.cpp?rev=363754=363753=363754=diff
==
--- cfe/trunk/test/SemaCXX/warn-everthing.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-everthing.cpp Tue Jun 18 16:40:17 2019
@@ -9,5 +9,6 @@ public:
 };
 
 void testPR12271() { // expected-warning {{no previous prototype for function 
'testPR12271'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this 

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D59744#1549229 , @efriedma wrote:

> If we're going to insert emms instructions automatically, it doesn't really 
> make sense to do it in the frontend; the backend could figure out the most 
> efficient placement itself.  (See lib/Target/X86/X86VZeroUpper.cpp, which 
> implements similar logic for AVX.)  The part I'd be worried about is the 
> potential performance hit from calling emms in places where other compilers 
> wouldn't, for code using MMX intrinsics.


It would certainly be simpler for the frontend if the backend did this — in 
fact, even if the "frontend" was going to do it, I would have suggested doing 
it as a pass over the emitted IR rather than a special case in IRGen.  Anyway, 
I'm open to any reasonable option; at this point, I'm just laying out the basic 
requirements for getting this patch back in, because the current patch is 
invalid given LLVM's current requirements.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-18 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev marked an inline comment as done.
anton-afanasyev added inline comments.



Comment at: clang/lib/Parse/ParseAST.cpp:167
   if (ADecl && !Consumer->HandleTopLevelDecl(ADecl.get()))
 return;
 }

@lebedev.ri This `return` should follow after 
`timeTraceProfilerEnd("Frontend",...)`, I'm to fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325



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


[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-18 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev added a comment.

In D63325#1549316 , @lebedev.ri wrote:

> Hmm, i'm only now noticing how fraglie this looks.
>  How do we know that `clang::ParseAST` will only ever be called with 
> `BackendConsumer` `ASTConsumer`?
>  How do we know that `BackendConsumer` will only ever be `ASTConsumer` from 
> `clang::ParseAST`?


This could be true by design. But I agree it's fragile. We can admit several 
`Frontend` sections though. But with this admission first variant with two 
`Frontend` `TimeTraceScope`'s is more preferrable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325



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


[PATCH] D59402: Suggestions to fix -Wmissing-{prototypes,variable-declarations}

2019-06-18 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
aaronpuchert marked an inline comment as done.
Closed by commit rL363749: Suggestions to fix 
-Wmissing-{prototypes,variable-declarations} (authored by aaronpuchert, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59402?vs=202483=205460#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59402

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/warn-missing-prototypes.c
  cfe/trunk/test/Sema/warn-missing-variable-declarations.c
  cfe/trunk/test/SemaCXX/warn-missing-prototypes.cpp
  cfe/trunk/test/SemaCXX/warn-missing-variable-declarations.cpp
  cfe/trunk/test/SemaOpenCL/warn-missing-prototypes.cl

Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -11899,8 +11899,11 @@
 while (prev && prev->isThisDeclarationADefinition())
   prev = prev->getPreviousDecl();
 
-if (!prev)
+if (!prev) {
   Diag(var->getLocation(), diag::warn_missing_variable_declarations) << var;
+  Diag(var->getTypeSpecStartLoc(), diag::note_static_for_internal_linkage)
+  << /* variable */ 0;
+}
   }
 
   // Cache the result of checking for constant initialization.
@@ -13364,6 +13367,13 @@
 ? FixItHint::CreateInsertion(FTL.getRParenLoc(), "void")
 : FixItHint{});
 }
+  } else {
+Diag(FD->getTypeSpecStartLoc(), diag::note_static_for_internal_linkage)
+<< /* function */ 1
+<< (FD->getStorageClass() == SC_None
+? FixItHint::CreateInsertion(FD->getTypeSpecStartLoc(),
+ "static ")
+: FixItHint{});
   }
 
   // GNU warning -Wstrict-prototypes
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4681,6 +4681,9 @@
 def warn_missing_variable_declarations : Warning<
   "no previous extern declaration for non-static variable %0">,
   InGroup>, DefaultIgnore;
+def note_static_for_internal_linkage : Note<
+  "declare 'static' if the %select{variable|function}0 is not intended to be "
+  "used outside of this translation unit">;
 def err_static_data_member_reinitialization :
   Error<"static data member %0 already has an initializer">;
 def err_redefinition : Error<"redefinition of %0">;
Index: cfe/trunk/test/SemaOpenCL/warn-missing-prototypes.cl
===
--- cfe/trunk/test/SemaOpenCL/warn-missing-prototypes.cl
+++ cfe/trunk/test/SemaOpenCL/warn-missing-prototypes.cl
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-prototypes %s
 
 void f() { } // expected-warning {{no previous prototype for function 'f'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
 
 // Don't warn about kernel functions.
 kernel void g() { }
Index: cfe/trunk/test/Sema/warn-missing-prototypes.c
===
--- cfe/trunk/test/Sema/warn-missing-prototypes.c
+++ cfe/trunk/test/Sema/warn-missing-prototypes.c
@@ -9,11 +9,17 @@
 static int g(int x) { return x; }
 
 int h(int x) { return x; } // expected-warning{{no previous prototype for function 'h'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:1-[[@LINE-2]]:1}:"static "
 
 static int g2();
 
 int g2(int x) { return x; }
 
+extern int g3(int x) { return x; } // expected-warning{{no previous prototype for function 'g3'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
+// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:{{.*}}-[[@LINE-2]]:{{.*}}}:"{{.*}}"
+
 void test(void);
 
 int h3(); // expected-note{{this declaration is not a prototype; add parameter declarations to make it one}}
@@ -28,6 +34,7 @@
 }
 
 int h2(int x) { return x; } // expected-warning{{no previous prototype for function 'h2'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
 int h3(int x) { return x; } // expected-warning{{no previous prototype for function 'h3'}}
 int h4(int x) { return x; }
 
Index: cfe/trunk/test/Sema/warn-missing-variable-declarations.c
===
--- cfe/trunk/test/Sema/warn-missing-variable-declarations.c
+++ 

r363749 - Suggestions to fix -Wmissing-{prototypes, variable-declarations}

2019-06-18 Thread Aaron Puchert via cfe-commits
Author: aaronpuchert
Date: Tue Jun 18 15:57:08 2019
New Revision: 363749

URL: http://llvm.org/viewvc/llvm-project?rev=363749=rev
Log:
Suggestions to fix -Wmissing-{prototypes,variable-declarations}

Summary:
I've found that most often the proper way to fix this warning is to add
`static`, because if the code otherwise compiles and links, the function
or variable is apparently not needed outside of the TU.

We can't provide a fix-it hint for variable declarations, because
multiple VarDecls can share the same type, and if we put static in front
of that, we affect all declared variables, some of which might have
previous declarations.

We also provide no fix-it hint for the rare case of an `extern` function
definition, because that would require removing `extern` and I have no
idea how to get the source location of the storage class specifier from
a FunctionDecl. I believe this information is only available earlier in
the AST construction from DeclSpec::getStorageClassSpecLoc(), but we
don't have that here.

Reviewed By: aaron.ballman

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/warn-missing-prototypes.c
cfe/trunk/test/Sema/warn-missing-variable-declarations.c
cfe/trunk/test/SemaCXX/warn-missing-prototypes.cpp
cfe/trunk/test/SemaCXX/warn-missing-variable-declarations.cpp
cfe/trunk/test/SemaOpenCL/warn-missing-prototypes.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=363749=363748=363749=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jun 18 15:57:08 
2019
@@ -4681,6 +4681,9 @@ def warn_strict_prototypes : Warning<
 def warn_missing_variable_declarations : Warning<
   "no previous extern declaration for non-static variable %0">,
   InGroup>, DefaultIgnore;
+def note_static_for_internal_linkage : Note<
+  "declare 'static' if the %select{variable|function}0 is not intended to be "
+  "used outside of this translation unit">;
 def err_static_data_member_reinitialization :
   Error<"static data member %0 already has an initializer">;
 def err_redefinition : Error<"redefinition of %0">;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=363749=363748=363749=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jun 18 15:57:08 2019
@@ -11899,8 +11899,11 @@ void Sema::CheckCompleteVariableDeclarat
 while (prev && prev->isThisDeclarationADefinition())
   prev = prev->getPreviousDecl();
 
-if (!prev)
+if (!prev) {
   Diag(var->getLocation(), diag::warn_missing_variable_declarations) << 
var;
+  Diag(var->getTypeSpecStartLoc(), diag::note_static_for_internal_linkage)
+  << /* variable */ 0;
+}
   }
 
   // Cache the result of checking for constant initialization.
@@ -13364,6 +13367,13 @@ Decl *Sema::ActOnFinishFunctionBody(Decl
 ? FixItHint::CreateInsertion(FTL.getRParenLoc(), 
"void")
 : FixItHint{});
 }
+  } else {
+Diag(FD->getTypeSpecStartLoc(), diag::note_static_for_internal_linkage)
+<< /* function */ 1
+<< (FD->getStorageClass() == SC_None
+? FixItHint::CreateInsertion(FD->getTypeSpecStartLoc(),
+ "static ")
+: FixItHint{});
   }
 
   // GNU warning -Wstrict-prototypes

Modified: cfe/trunk/test/Sema/warn-missing-prototypes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-missing-prototypes.c?rev=363749=363748=363749=diff
==
--- cfe/trunk/test/Sema/warn-missing-prototypes.c (original)
+++ cfe/trunk/test/Sema/warn-missing-prototypes.c Tue Jun 18 15:57:08 2019
@@ -9,11 +9,17 @@ int f(int x) { return x; } // expected-w
 static int g(int x) { return x; }
 
 int h(int x) { return x; } // expected-warning{{no previous prototype for 
function 'h'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:1-[[@LINE-2]]:1}:"static "
 
 static int g2();
 
 int g2(int x) { return x; }
 
+extern int g3(int x) { return x; } // expected-warning{{no previous prototype 
for function 'g3'}}
+// expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
+// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:{{.*}}-[[@LINE-2]]:{{.*}}}:"{{.*}}"
+
 void 

[PATCH] D62750: Show note for -Wmissing-prototypes for functions with parameters

2019-06-18 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363748: Show note for -Wmissing-prototypes for functions 
with parameters (authored by aaronpuchert, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62750

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/warn-missing-prototypes.c

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4672,7 +4672,8 @@
   "no previous prototype for function %0">,
   InGroup>, DefaultIgnore;
 def note_declaration_not_a_prototype : Note<
-  "this declaration is not a prototype; add 'void' to make it a prototype for a zero-parameter function">;
+  "this declaration is not a prototype; add %select{'void'|parameter declarations}0 "
+  "to make it %select{a prototype for a zero-parameter function|one}0">;
 def warn_strict_prototypes : Warning<
   "this %select{function declaration is not|block declaration is not|"
   "old-style function definition is not preceded by}0 a prototype">,
Index: cfe/trunk/test/Sema/warn-missing-prototypes.c
===
--- cfe/trunk/test/Sema/warn-missing-prototypes.c
+++ cfe/trunk/test/Sema/warn-missing-prototypes.c
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wmissing-prototypes -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wmissing-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
-int f();
+int f(); // expected-note{{this declaration is not a prototype; add parameter declarations to make it one}}
+// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}-[[@LINE-1]]:{{.*}}}:"{{.*}}"
 
 int f(int x) { return x; } // expected-warning{{no previous prototype for function 'f'}}
 
@@ -15,7 +16,8 @@
 
 void test(void);
 
-int h3();
+int h3(); // expected-note{{this declaration is not a prototype; add parameter declarations to make it one}}
+// CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:{{.*}}-[[@LINE-1]]:{{.*}}}:"{{.*}}"
 int h4(int);
 int h4();
 
@@ -38,6 +40,5 @@
 int main(void) { return 0; }
 
 void not_a_prototype_test(); // expected-note{{this declaration is not a prototype; add 'void' to make it a prototype for a zero-parameter function}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:27-[[@LINE-1]]:27}:"void"
 void not_a_prototype_test() { } // expected-warning{{no previous prototype for function 'not_a_prototype_test'}}
-
-// CHECK: fix-it:"{{.*}}":{40:27-40:27}:"void"
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -12777,8 +12777,9 @@
   Consumer.HandleInlineFunctionDefinition(D);
 }
 
-static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
- const FunctionDecl*& PossibleZeroParamPrototype) {
+static bool
+ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
+const FunctionDecl *) {
   // Don't warn about invalid declarations.
   if (FD->isInvalidDecl())
 return false;
@@ -12815,7 +12816,6 @@
   if (FD->isDeleted())
 return false;
 
-  bool MissingPrototype = true;
   for (const FunctionDecl *Prev = FD->getPreviousDecl();
Prev; Prev = Prev->getPreviousDecl()) {
 // Ignore any declarations that occur in function or method
@@ -12823,13 +12823,11 @@
 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
   continue;
 
-MissingPrototype = !Prev->getType()->isFunctionProtoType();
-if (FD->getNumParams() == 0)
-  PossibleZeroParamPrototype = Prev;
-break;
+PossiblePrototype = Prev;
+return Prev->getType()->isFunctionNoProtoType();
   }
 
-  return MissingPrototype;
+  return true;
 }
 
 void
@@ -13349,21 +13347,22 @@
 //   prototype declaration. This warning is issued even if the
 //   definition itself provides a prototype. The aim is to detect
 //   global functions that fail to be declared in header files.
-const FunctionDecl *PossibleZeroParamPrototype = nullptr;
-if (ShouldWarnAboutMissingPrototype(FD, PossibleZeroParamPrototype)) {
+const FunctionDecl *PossiblePrototype = nullptr;
+if (ShouldWarnAboutMissingPrototype(FD, PossiblePrototype)) {
   Diag(FD->getLocation(), diag::warn_missing_prototype) << FD;
 
-  if (PossibleZeroParamPrototype) {
+  if (PossiblePrototype) {
 // We found a declaration that is not a prototype,
 // but that could be a zero-parameter prototype
-if (TypeSourceInfo *TI =
-PossibleZeroParamPrototype->getTypeSourceInfo()) {
+if 

r363748 - Show note for -Wmissing-prototypes for functions with parameters

2019-06-18 Thread Aaron Puchert via cfe-commits
Author: aaronpuchert
Date: Tue Jun 18 15:52:39 2019
New Revision: 363748

URL: http://llvm.org/viewvc/llvm-project?rev=363748=rev
Log:
Show note for -Wmissing-prototypes for functions with parameters

Summary:
There was a search for non-prototype declarations for the function, but
we only showed the results for zero-parameter functions. Now we show the
note for functions with parameters as well, but we omit the fix-it hint
suggesting to add `void`.

Reviewed By: aaron.ballman

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/warn-missing-prototypes.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=363748=363747=363748=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jun 18 15:52:39 
2019
@@ -4672,7 +4672,8 @@ def warn_missing_prototype : Warning<
   "no previous prototype for function %0">,
   InGroup>, DefaultIgnore;
 def note_declaration_not_a_prototype : Note<
-  "this declaration is not a prototype; add 'void' to make it a prototype for 
a zero-parameter function">;
+  "this declaration is not a prototype; add %select{'void'|parameter 
declarations}0 "
+  "to make it %select{a prototype for a zero-parameter function|one}0">;
 def warn_strict_prototypes : Warning<
   "this %select{function declaration is not|block declaration is not|"
   "old-style function definition is not preceded by}0 a prototype">,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=363748=363747=363748=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jun 18 15:52:39 2019
@@ -12777,8 +12777,9 @@ void Sema::ActOnFinishInlineFunctionDef(
   Consumer.HandleInlineFunctionDefinition(D);
 }
 
-static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
- const FunctionDecl*& PossibleZeroParamPrototype) {
+static bool
+ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
+const FunctionDecl *) {
   // Don't warn about invalid declarations.
   if (FD->isInvalidDecl())
 return false;
@@ -12815,7 +12816,6 @@ static bool ShouldWarnAboutMissingProtot
   if (FD->isDeleted())
 return false;
 
-  bool MissingPrototype = true;
   for (const FunctionDecl *Prev = FD->getPreviousDecl();
Prev; Prev = Prev->getPreviousDecl()) {
 // Ignore any declarations that occur in function or method
@@ -12823,13 +12823,11 @@ static bool ShouldWarnAboutMissingProtot
 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
   continue;
 
-MissingPrototype = !Prev->getType()->isFunctionProtoType();
-if (FD->getNumParams() == 0)
-  PossibleZeroParamPrototype = Prev;
-break;
+PossiblePrototype = Prev;
+return Prev->getType()->isFunctionNoProtoType();
   }
 
-  return MissingPrototype;
+  return true;
 }
 
 void
@@ -13349,21 +13347,22 @@ Decl *Sema::ActOnFinishFunctionBody(Decl
 //   prototype declaration. This warning is issued even if the
 //   definition itself provides a prototype. The aim is to detect
 //   global functions that fail to be declared in header files.
-const FunctionDecl *PossibleZeroParamPrototype = nullptr;
-if (ShouldWarnAboutMissingPrototype(FD, PossibleZeroParamPrototype)) {
+const FunctionDecl *PossiblePrototype = nullptr;
+if (ShouldWarnAboutMissingPrototype(FD, PossiblePrototype)) {
   Diag(FD->getLocation(), diag::warn_missing_prototype) << FD;
 
-  if (PossibleZeroParamPrototype) {
+  if (PossiblePrototype) {
 // We found a declaration that is not a prototype,
 // but that could be a zero-parameter prototype
-if (TypeSourceInfo *TI =
-PossibleZeroParamPrototype->getTypeSourceInfo()) {
+if (TypeSourceInfo *TI = PossiblePrototype->getTypeSourceInfo()) {
   TypeLoc TL = TI->getTypeLoc();
   if (FunctionNoProtoTypeLoc FTL = TL.getAs())
-Diag(PossibleZeroParamPrototype->getLocation(),
+Diag(PossiblePrototype->getLocation(),
  diag::note_declaration_not_a_prototype)
-<< PossibleZeroParamPrototype
-<< FixItHint::CreateInsertion(FTL.getRParenLoc(), "void");
+<< (FD->getNumParams() != 0)
+<< (FD->getNumParams() == 0
+? FixItHint::CreateInsertion(FTL.getRParenLoc(), 
"void")
+: FixItHint{});
 }
   }
 

Modified: cfe/trunk/test/Sema/warn-missing-prototypes.c
URL: 

[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Hmm, i'm only now noticing how fraglie this looks.
How do we know that `clang::ParseAST` will only ever be called with 
`BackendConsumer` `ASTConsumer`?
How do we know that `BackendConsumer` will only ever be `ASTConsumer` from 
`clang::ParseAST`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325



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


[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-18 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev marked 2 inline comments as done.
anton-afanasyev added inline comments.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:250-252
+  // Finish "Frontend" section starting inside clang::ParseAST()
+  if (llvm::timeTraceProfilerEnabled())
+llvm::timeTraceProfilerEnd();

lebedev.ri wrote:
> anton-afanasyev wrote:
> > lebedev.ri wrote:
> > > I think i'm missing a point here.
> > > Why do we want to end `"Frontend"` section here,  exclude all this 
> > > following diag/optremark/etc stuff?
> > The answer is below, we have `EmitBackendOutput()` there, calling Backend 
> > actions.
> So, because we don't want "backend" timer to be within "frontend" timer.
> Can you please add that as a comment here? :)
Ok, done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325



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


[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-18 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev updated this revision to Diff 205451.
anton-afanasyev marked an inline comment as done.
anton-afanasyev added a comment.

Updated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Parse/ParseAST.cpp
  clang/test/Driver/check-time-trace-sections.cpp
  clang/test/Driver/check-time-trace-sections.py
  llvm/lib/Support/TimeProfiler.cpp


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -65,7 +65,7 @@
 E.Duration = steady_clock::now() - E.Start;
 
 // Only include sections longer than TimeTraceGranularity msec.
-if (duration_cast(E.Duration).count() > TimeTraceGranularity)
+if (duration_cast(E.Duration).count() >= 
TimeTraceGranularity)
   Entries.emplace_back(E);
 
 // Track total time taken by each "name", but only the topmost levels of
Index: clang/test/Driver/check-time-trace-sections.py
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-sections.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import json, sys
+
+def is_inside(range1, range2):
+a = range1["ts"]; b = a + range1["dur"]
+c = range2["ts"]; d = c + range2["dur"]
+return (a >= c and a <= d) and (b >= c and b <= d)
+
+events = json.loads(sys.stdin.read())["traceEvents"]
+codegens = filter(lambda x: x["name"] == "CodeGen Function", events)
+frontends = filter(lambda x: x["name"] == "Frontend", events)
+
+if not len(frontends) == 1:
+sys.exit("There should be exactly one Frontend section!")
+
+frontend = frontends[0]
+
+if not all([is_inside(codegen, frontend) for codegen in codegens]):
+sys.exit("Not all CodeGen sections are inside Frontend section!")
Index: clang/test/Driver/check-time-trace-sections.cpp
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-sections.cpp
@@ -0,0 +1,7 @@
+// REQUIRES: shell
+// RUN: %clangxx -S -ftime-trace -mllvm --time-trace-granularity=0 -o 
%T/check-time-trace-sections %s
+// RUN: cat %T/check-time-trace-sections.json | %python 
%S/check-time-trace-sections.py
+
+template 
+void foo(T) {}
+void bar() { foo(0); }
Index: clang/lib/Parse/ParseAST.cpp
===
--- clang/lib/Parse/ParseAST.cpp
+++ clang/lib/Parse/ParseAST.cpp
@@ -150,8 +150,12 @@
   // after the pragma, there won't be any tokens or a Lexer.
   bool HaveLexer = S.getPreprocessor().getCurrentLexer();
 
+  // Start "Frontend" section finishing inside clang::HandleTranslationUnit()
+  if (llvm::timeTraceProfilerEnabled())
+llvm::timeTraceProfilerBegin("Frontend", StringRef(""));
+
   if (HaveLexer) {
-llvm::TimeTraceScope TimeScope("Frontend", StringRef(""));
+llvm::TimeTraceScope TimeScope("Lexing", StringRef(""));
 P.Initialize();
 Parser::DeclGroupPtrTy ADecl;
 for (bool AtEOF = P.ParseFirstTopLevelDecl(ADecl); !AtEOF;
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/YAMLTraits.h"
@@ -246,6 +247,12 @@
 IRGenFinished = true;
   }
 
+  // Finish "Frontend" section starting inside clang::ParseAST()
+  // We don't want "Backend" section to turn out within "Frontend" section,
+  // so finishing it here before EmitBackendOutput() and possible return's.
+  if (llvm::timeTraceProfilerEnabled())
+llvm::timeTraceProfilerEnd();
+
   // Silently ignore if we weren't initialized for some reason.
   if (!getModule())
 return;


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -65,7 +65,7 @@
 E.Duration = steady_clock::now() - E.Start;
 
 // Only include sections longer than TimeTraceGranularity msec.
-if (duration_cast(E.Duration).count() > TimeTraceGranularity)
+if (duration_cast(E.Duration).count() >= TimeTraceGranularity)
   Entries.emplace_back(E);
 
 // Track total time taken by each "name", but only the topmost levels of
Index: clang/test/Driver/check-time-trace-sections.py
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-sections.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import json, sys
+
+def is_inside(range1, range2):
+

[PATCH] D63519: [analyzer] exploded-graph-rewriter: Fix escaping and unescaping of StringRegions.

2019-06-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 205449.
NoQ added a comment.

Oh, right, thanks!


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

https://reviews.llvm.org/D63519

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/exploded-graph-rewriter/escapes.c
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/utils/analyzer/exploded-graph-rewriter.py


Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -284,6 +284,7 @@
 .replace('\\"', '"') \
 .replace('\\{', '{') \
 .replace('\\}', '}') \
+.replace('', '\\') \
 .replace('\\<', '<') \
 .replace('\\>', '>') \
 .rstrip(',')
Index: clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
===
--- clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
+++ clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
@@ -15,4 +15,4 @@
 config.clang_src_dir,
 'utils', 'analyzer')
 
-config.suffixes = ['.dot']
+config.suffixes.add('.dot')
Index: clang/test/Analysis/exploded-graph-rewriter/escapes.c
===
--- /dev/null
+++ clang/test/Analysis/exploded-graph-rewriter/escapes.c
@@ -0,0 +1,18 @@
+// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
+// RUN: %clang_cc1 -analyze -analyzer-checker=core \
+// RUN: -analyzer-dump-egraph=%t.dot %s
+// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
+
+// FIXME: Substitution doesn't seem to work on Windows.
+// UNSUPPORTED: system-windows
+
+void string_region_escapes() {
+  // CHECK: const char *const foo = "foo";
+  // CHECK-SAME: Store:
+  // CHECK-SAME: foo0
+  // CHECK-SAME: Element\{"foo",0 S64b,char\}
+  // CHECK-SAME: Environment:
+  // CHECK-SAME: "foo"
+  // CHECK-SAME: Element\{"foo",0 S64b,char\}
+  const char *const foo = "foo";
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -210,6 +210,7 @@
   void printJson(raw_ostream , const char *NL = "\n",
  unsigned int Space = 0, bool IsDot = false) const {
 for (iterator I = begin(); I != end(); ++I) {
+  // TODO: We might need a .printJson for I.getKey() as well.
   Indent(Out, Space, IsDot)
   << "{ \"cluster\": \"" << I.getKey() << "\", \"pointer\": \""
   << (const void *)I.getKey() << "\", \"items\": [" << NL;
@@ -217,8 +218,9 @@
   ++Space;
   const ClusterBindings  = I.getData();
   for (ClusterBindings::iterator CI = CB.begin(); CI != CB.end(); ++CI) {
-Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": \""
-  << CI.getData() << "\" }";
+Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": ";
+CI.getData().printJson(Out, /*AddQuotes=*/true);
+Out << " }";
 if (std::next(CI) != CB.end())
   Out << ',';
 Out << NL;


Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -284,6 +284,7 @@
 .replace('\\"', '"') \
 .replace('\\{', '{') \
 .replace('\\}', '}') \
+.replace('', '\\') \
 .replace('\\<', '<') \
 .replace('\\>', '>') \
 .rstrip(',')
Index: clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
===
--- clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
+++ clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
@@ -15,4 +15,4 @@
 config.clang_src_dir,
 'utils', 'analyzer')
 
-config.suffixes = ['.dot']
+config.suffixes.add('.dot')
Index: clang/test/Analysis/exploded-graph-rewriter/escapes.c
===
--- /dev/null
+++ 

[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked an inline comment as done.
lebedev.ri added inline comments.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:250-252
+  // Finish "Frontend" section starting inside clang::ParseAST()
+  if (llvm::timeTraceProfilerEnabled())
+llvm::timeTraceProfilerEnd();

anton-afanasyev wrote:
> lebedev.ri wrote:
> > I think i'm missing a point here.
> > Why do we want to end `"Frontend"` section here,  exclude all this 
> > following diag/optremark/etc stuff?
> The answer is below, we have `EmitBackendOutput()` there, calling Backend 
> actions.
So, because we don't want "backend" timer to be within "frontend" timer.
Can you please add that as a comment here? :)



Comment at: clang/test/Driver/check-time-trace-sections.py:1
+#!/usr/bin/env python
+

anton-afanasyev wrote:
> lebedev.ri wrote:
> > Does some other test already require python?
> Sorry, what do you mean? I see many tests inside `clang/test/` and 
> `llvm/test/` using python when Filecheck is not enough. Mostly they are using 
> `python -c ...` as part of the pipe, but there are py-files as well.
I guess that was a dumb question, since lit is python-based.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325



___
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-06-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/SemaSYCL/device-attributes.cpp:3
+
+[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' 
attribute only applies to functions}}
+__attribute((sycl_kernel)) int gv3 = 0; // expected-warning {{'sycl_kernel' 
attribute only applies to functions}}

Fznamznon wrote:
> aaron.ballman wrote:
> > I'd like to see some more tests covering less obvious scenarios. Can I add 
> > this attribute to a lambda? What about a member function? How does it work 
> > with virtual functions? That sort of thing.
> Actually there is no restrictions for adding this attribute to any function 
> to outline device code so I just checked the simplest variant.
> 
> But I'm working on new patch which will put some requirements on function 
> which is marked with `sycl_kernel` attribute. 
> This new patch will add generation of OpenCL kernel from function marked with 
> `sycl_kernel` attribute. The main idea of this approach is described in this 
> [[ 
> https://github.com/intel/llvm/blob/sycl/sycl/doc/SYCL_compiler_and_runtime_design.md#lowering-of-lambda-function-objects-and-named-function-objects
>  | document ]] (in this document generated kernel is called "kernel wrapper").
> And to be able to generate OpenCL kernel using function marked with 
> `sycl_kernel` attribute we put some requirements on this function, for 
> example it must be a template function. You can find these requirements and 
> example of proper function which can be marked with `sycl_kernel` in this [[ 
> https://github.com/intel/llvm/pull/177#discussion_r290451286 | comment ]] .
> 
> 
> Actually there is no restrictions for adding this attribute to any function 
> to outline device code so I just checked the simplest variant.

So there are no concerns about code like:
```
struct Base {
  __attribute__((sycl_kernel)) virtual void foo();
  virtual void bar();
};

struct Derived : Base {
  void foo() override;
  __attribute__((sycl_kernel)) void bar() override;
};

void f(Base *B, Derived *D) {
  // Will all of these "do the right thing"?
  B->foo();
  B->bar();

  D->foo();
  D->bar();
}
```


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


[PATCH] D63519: [analyzer] exploded-graph-rewriter: Fix escaping and unescaping of StringRegions.

2019-06-18 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso marked an inline comment as done.
Charusso added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:222
+Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": ";
+CI.getData().printJson(Out, true);
+Out << " }";

Could you inject `/*AddQuotes=*/`?



Comment at: clang/test/Analysis/exploded-graph-rewriter/escapes.c:3
+// RUN: %clang_cc1 -analyze -analyzer-checker=core \
+// RUN: -analyzer-dump-egraph=%t.dot %s
+// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s

I like that styling.



Comment at: clang/utils/analyzer/exploded-graph-rewriter.py:287
 .replace('\\}', '}') \
+.replace('', '\\') \
 .replace('\\<', '<') \

I think this is the correct approach.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63519



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


[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-18 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev updated this revision to Diff 205446.
anton-afanasyev marked 4 inline comments as done.
anton-afanasyev added a comment.

Updated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Parse/ParseAST.cpp
  clang/test/Driver/check-time-trace-sections.cpp
  clang/test/Driver/check-time-trace-sections.py
  llvm/lib/Support/TimeProfiler.cpp


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -65,7 +65,7 @@
 E.Duration = steady_clock::now() - E.Start;
 
 // Only include sections longer than TimeTraceGranularity msec.
-if (duration_cast(E.Duration).count() > TimeTraceGranularity)
+if (duration_cast(E.Duration).count() >= 
TimeTraceGranularity)
   Entries.emplace_back(E);
 
 // Track total time taken by each "name", but only the topmost levels of
Index: clang/test/Driver/check-time-trace-sections.py
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-sections.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import json, sys
+
+def is_inside(range1, range2):
+a = range1["ts"]; b = a + range1["dur"]
+c = range2["ts"]; d = c + range2["dur"]
+return (a >= c and a <= d) and (b >= c and b <= d)
+
+events = json.loads(sys.stdin.read())["traceEvents"]
+codegens = filter(lambda x: x["name"] == "CodeGen Function", events)
+frontends = filter(lambda x: x["name"] == "Frontend", events)
+
+if not len(frontends) == 1:
+sys.exit("There should be exactly one Frontend section!")
+
+frontend = frontends[0]
+
+if not all([is_inside(codegen, frontend) for codegen in codegens]):
+sys.exit("Not all CodeGen sections are inside Frontend section!")
Index: clang/test/Driver/check-time-trace-sections.cpp
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-sections.cpp
@@ -0,0 +1,7 @@
+// REQUIRES: shell
+// RUN: %clangxx -S -ftime-trace -mllvm --time-trace-granularity=0 -o 
%T/check-time-trace-sections %s
+// RUN: cat %T/check-time-trace-sections.json | %python 
%S/check-time-trace-sections.py
+
+template 
+void foo(T) {}
+void bar() { foo(0); }
Index: clang/lib/Parse/ParseAST.cpp
===
--- clang/lib/Parse/ParseAST.cpp
+++ clang/lib/Parse/ParseAST.cpp
@@ -150,8 +150,12 @@
   // after the pragma, there won't be any tokens or a Lexer.
   bool HaveLexer = S.getPreprocessor().getCurrentLexer();
 
+  // Start "Frontend" section finishing inside clang::HandleTranslationUnit()
+  if (llvm::timeTraceProfilerEnabled())
+llvm::timeTraceProfilerBegin("Frontend", StringRef(""));
+
   if (HaveLexer) {
-llvm::TimeTraceScope TimeScope("Frontend", StringRef(""));
+llvm::TimeTraceScope TimeScope("Lexing", StringRef(""));
 P.Initialize();
 Parser::DeclGroupPtrTy ADecl;
 for (bool AtEOF = P.ParseFirstTopLevelDecl(ADecl); !AtEOF;
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/YAMLTraits.h"
@@ -246,6 +247,10 @@
 IRGenFinished = true;
   }
 
+  // Finish "Frontend" section starting inside clang::ParseAST()
+  if (llvm::timeTraceProfilerEnabled())
+llvm::timeTraceProfilerEnd();
+
   // Silently ignore if we weren't initialized for some reason.
   if (!getModule())
 return;


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -65,7 +65,7 @@
 E.Duration = steady_clock::now() - E.Start;
 
 // Only include sections longer than TimeTraceGranularity msec.
-if (duration_cast(E.Duration).count() > TimeTraceGranularity)
+if (duration_cast(E.Duration).count() >= TimeTraceGranularity)
   Entries.emplace_back(E);
 
 // Track total time taken by each "name", but only the topmost levels of
Index: clang/test/Driver/check-time-trace-sections.py
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-sections.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import json, sys
+
+def is_inside(range1, range2):
+a = range1["ts"]; b = a + range1["dur"]
+c = range2["ts"]; d = c + range2["dur"]
+return (a >= c and a <= d) and (b >= c and b <= d)
+
+events = 

[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-18 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev marked 10 inline comments as done.
anton-afanasyev added inline comments.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:250-252
+  // Finish "Frontend" section starting inside clang::ParseAST()
+  if (llvm::timeTraceProfilerEnabled())
+llvm::timeTraceProfilerEnd();

lebedev.ri wrote:
> I think i'm missing a point here.
> Why do we want to end `"Frontend"` section here,  exclude all this following 
> diag/optremark/etc stuff?
The answer is below, we have `EmitBackendOutput()` there, calling Backend 
actions.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:256
   if (!getModule())
 return;
 

Also the function can return here, without finishing `Frontend` section, if it 
is below.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:306
 
   EmitBackendOutput(Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts,
 LangOpts, C.getTargetInfo().getDataLayout(),

@lebedev.ri We have `EmitBackendOutput()` here, calling Backend actions.



Comment at: clang/lib/Parse/ParseAST.cpp:154
   if (HaveLexer) {
-llvm::TimeTraceScope TimeScope("Frontend", StringRef(""));
 P.Initialize();

lebedev.ri wrote:
> Why not keep this as `"Lexing"`?
Hmm... Thanks, I'm to keep it with this name.



Comment at: clang/lib/Parse/ParseAST.cpp:182
   finalize(S.TemplateInstCallbacks, S);
 
   std::swap(OldCollectStats, S.CollectStats);

lebedev.ri wrote:
> I.e. why do we not want to end it here, where the other stats are printed?
Cause `HandleTranslationUnit()` contains Backend calling.



Comment at: clang/test/Driver/check-time-trace-sections.py:1
+#!/usr/bin/env python
+

lebedev.ri wrote:
> Does some other test already require python?
Sorry, what do you mean? I see many tests inside `clang/test/` and `llvm/test/` 
using python when Filecheck is not enough. Mostly they are using `python -c 
...` as part of the pipe, but there are py-files as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325



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


[PATCH] D63462: [analyzer] JsonSupport: Escape escapes

2019-06-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

My problem is demonstrated (and solved) by D63519 
. If i revert my changes but apply this patch 
instead, my test keeps failing.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63462



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


[PATCH] D63519: [analyzer] exploded-graph-rewriter: Fix escaping and unescaping of StringRegions.

2019-06-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added a reviewer: Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

Additionally, add a forgotten escape for Store values.


Repository:
  rC Clang

https://reviews.llvm.org/D63519

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/exploded-graph-rewriter/escapes.c
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/utils/analyzer/exploded-graph-rewriter.py


Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -284,6 +284,7 @@
 .replace('\\"', '"') \
 .replace('\\{', '{') \
 .replace('\\}', '}') \
+.replace('', '\\') \
 .replace('\\<', '<') \
 .replace('\\>', '>') \
 .rstrip(',')
Index: clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
===
--- clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
+++ clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
@@ -15,4 +15,4 @@
 config.clang_src_dir,
 'utils', 'analyzer')
 
-config.suffixes = ['.dot']
+config.suffixes.add('.dot')
Index: clang/test/Analysis/exploded-graph-rewriter/escapes.c
===
--- /dev/null
+++ clang/test/Analysis/exploded-graph-rewriter/escapes.c
@@ -0,0 +1,18 @@
+// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
+// RUN: %clang_cc1 -analyze -analyzer-checker=core \
+// RUN: -analyzer-dump-egraph=%t.dot %s
+// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
+
+// FIXME: Substitution doesn't seem to work on Windows.
+// UNSUPPORTED: system-windows
+
+void string_region_escapes() {
+  // CHECK: const char *const foo = "foo";
+  // CHECK-SAME: Store:
+  // CHECK-SAME: foo0
+  // CHECK-SAME: Element\{"foo",0 S64b,char\}
+  // CHECK-SAME: Environment:
+  // CHECK-SAME: "foo"
+  // CHECK-SAME: Element\{"foo",0 S64b,char\}
+  const char *const foo = "foo";
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -210,6 +210,7 @@
   void printJson(raw_ostream , const char *NL = "\n",
  unsigned int Space = 0, bool IsDot = false) const {
 for (iterator I = begin(); I != end(); ++I) {
+  // TODO: We might need a .printJson for I.getKey() as well.
   Indent(Out, Space, IsDot)
   << "{ \"cluster\": \"" << I.getKey() << "\", \"pointer\": \""
   << (const void *)I.getKey() << "\", \"items\": [" << NL;
@@ -217,8 +218,9 @@
   ++Space;
   const ClusterBindings  = I.getData();
   for (ClusterBindings::iterator CI = CB.begin(); CI != CB.end(); ++CI) {
-Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": \""
-  << CI.getData() << "\" }";
+Indent(Out, Space, IsDot) << "{ " << CI.getKey() << ", \"value\": ";
+CI.getData().printJson(Out, true);
+Out << " }";
 if (std::next(CI) != CB.end())
   Out << ',';
 Out << NL;


Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -284,6 +284,7 @@
 .replace('\\"', '"') \
 .replace('\\{', '{') \
 .replace('\\}', '}') \
+.replace('', '\\') \
 .replace('\\<', '<') \
 .replace('\\>', '>') \
 .rstrip(',')
Index: clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
===
--- clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
+++ clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
@@ -15,4 +15,4 @@
 config.clang_src_dir,
 'utils', 'analyzer')
 
-config.suffixes = ['.dot']
+config.suffixes.add('.dot')
Index: 

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

If we're going to insert emms instructions automatically, it doesn't really 
make sense to do it in the frontend; the backend could figure out the most 
efficient placement itself.  (See lib/Target/X86/X86VZeroUpper.cpp, which 
implements similar logic for AVX.)  The part I'd be worried about is the 
potential performance hit from calling emms in places where other compilers 
wouldn't, for code using MMX intrinsics.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


[PATCH] D62761: [analyzer] exploded-graph-rewriter: Implement a --diff mode.

2019-06-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 205443.
NoQ added a comment.

Don't try to sneak in an unrelated change.


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

https://reviews.llvm.org/D62761

Files:
  clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/program_points.dot
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/test/Analysis/exploded-graph-rewriter/store_diff.dot
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -18,6 +18,13 @@
 import re
 
 
+# A helper function for finding the difference between two dictionaries.
+def diff_dicts(curr, prev):
+removed = [k for k in prev if k not in curr or curr[k] != prev[k]]
+added = [k for k in curr if k not in prev or curr[k] != prev[k]]
+return (removed, added)
+
+
 # A deserialized source location.
 class SourceLocation(object):
 def __init__(self, json_loc):
@@ -47,13 +54,21 @@
 self.block_id = json_pp['block_id']
 
 
-# A value of a single expression in a deserialized Environment.
-class EnvironmentBinding(object):
-def __init__(self, json_eb):
-super(EnvironmentBinding, self).__init__()
-self.stmt_id = json_eb['stmt_id']
-self.pretty = json_eb['pretty']
-self.value = json_eb['value']
+# A single expression acting as a key in a deserialized Environment.
+class EnvironmentBindingKey(object):
+def __init__(self, json_ek):
+super(EnvironmentBindingKey, self).__init__()
+self.stmt_id = json_ek['stmt_id']
+self.pretty = json_ek['pretty']
+
+def _key(self):
+return self.stmt_id
+
+def __eq__(self, other):
+return self._key() == other._key()
+
+def __hash__(self):
+return hash(self._key())
 
 
 # Deserialized description of a location context.
@@ -65,6 +80,15 @@
 self.decl = json_frame['calling']
 self.line = json_frame['call_line']
 
+def _key(self):
+return self.lctx_id
+
+def __eq__(self, other):
+return self._key() == other._key()
+
+def __hash__(self):
+return hash(self._key())
+
 
 # A group of deserialized Environment bindings that correspond to a specific
 # location context.
@@ -72,8 +96,17 @@
 def __init__(self, json_frame):
 super(EnvironmentFrame, self).__init__()
 self.location_context = LocationContext(json_frame)
-self.bindings = [EnvironmentBinding(b) for b in json_frame['items']] \
-if json_frame['items'] is not None else []
+self.bindings = collections.OrderedDict(
+[(EnvironmentBindingKey(b),
+  b['value']) for b in json_frame['items']]
+if json_frame['items'] is not None else [])
+
+def diff_bindings(self, prev):
+return diff_dicts(self.bindings, prev.bindings)
+
+def is_different(self, prev):
+removed, added = self.diff_bindings(prev)
+return len(removed) != 0 or len(added) != 0
 
 
 # A deserialized Environment.
@@ -82,14 +115,46 @@
 super(Environment, self).__init__()
 self.frames = [EnvironmentFrame(f) for f in json_e]
 
+def diff_frames(self, prev):
+# TODO: It's difficult to display a good diff when frame numbers shift.
+if len(self.frames) != len(prev.frames):
+return None
+
+updated = []
+for i in range(len(self.frames)):
+f = self.frames[i]
+prev_f = prev.frames[i]
+if f.location_context == prev_f.location_context:
+if f.is_different(prev_f):
+updated.append(i)
+else:
+# We have the whole frame replaced with another frame.
+# TODO: Produce a nice diff.
+return None
+
+# TODO: Add support for added/removed.
+return updated
+
+def is_different(self, prev):
+updated = self.diff_frames(prev)
+return updated is None or len(updated) > 0
+
+
+# A single binding key in a deserialized RegionStore cluster.
+class StoreBindingKey(object):
+def __init__(self, json_sk):
+super(StoreBindingKey, self).__init__()
+self.kind = json_sk['kind']
+self.offset = json_sk['offset']
 
-# A single binding in a deserialized RegionStore cluster.
-class StoreBinding(object):
-def __init__(self, json_sb):
-super(StoreBinding, self).__init__()
-self.kind = json_sb['kind']
-self.offset = json_sb['offset']
-self.value = json_sb['value']
+def _key(self):
+return (self.kind, self.offset)
+
+def __eq__(self, other):
+return self._key() == other._key()
+
+def __hash__(self):
+return hash(self._key())
 
 
 # A single cluster of the 

[PATCH] D63462: [analyzer] JsonSupport: Escape escapes

2019-06-18 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D63462#1549225 , @NoQ wrote:

> I mean, i'm removing backslashes but you're adding more backslashes. 
> Therefore i think we're talking about different issues.


You *have to* remove backslashes, because sometimes we have `` so two of 
them packed together. Then when you remove it, it will be only one (`\\` ), 
which is handled by JSON properly. Sadly it is very strict and cannot predict 
two should not be a problem.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63462



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


[PATCH] D63462: [analyzer] JsonSupport: Escape escapes

2019-06-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I mean, i'm removing backslashes but you're adding more backslashes. Therefore 
i think we're talking about different issues.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63462



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


[PATCH] D63518: WIP BitStream reader: propagate errors

2019-06-18 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

This is still a work in progress. I still have to debug clang tests that fail, 
and compile / fix more than clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63518



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


[PATCH] D63290: Unify DependencyFileGenerator class and DependencyCollector interface

2019-06-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 205438.
arphaman marked 3 inline comments as done.
arphaman added a comment.

Address review comments.


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

https://reviews.llvm.org/D63290

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Frontend/Utils.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp

Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -32,8 +32,10 @@
 struct DepCollectorPPCallbacks : public PPCallbacks {
   DependencyCollector 
   SourceManager 
-  DepCollectorPPCallbacks(DependencyCollector , SourceManager )
-  : DepCollector(L), SM(SM) { }
+  DiagnosticsEngine 
+  DepCollectorPPCallbacks(DependencyCollector , SourceManager ,
+  DiagnosticsEngine )
+  : DepCollector(L), SM(SM), Diags(Diags) {}
 
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
@@ -57,6 +59,16 @@
 /*IsModuleFile*/false, /*IsMissing*/false);
   }
 
+  void FileSkipped(const FileEntry , const Token ,
+   SrcMgr::CharacteristicKind FileType) override {
+StringRef Filename =
+llvm::sys::path::remove_leading_dotslash(SkippedFile.getName());
+DepCollector.maybeAddDependency(Filename, /*FromModule=*/false,
+/*IsSystem=*/isSystem(FileType),
+/*IsModuleFile=*/false,
+/*IsMissing=*/false);
+  }
+
   void InclusionDirective(SourceLocation HashLoc, const Token ,
   StringRef FileName, bool IsAngled,
   CharSourceRange FilenameRange, const FileEntry *File,
@@ -70,9 +82,20 @@
 // Files that actually exist are handled by FileChanged.
   }
 
-  void EndOfMainFile() override {
-DepCollector.finishedMainFile();
+  void HasInclude(SourceLocation Loc, StringRef SpelledFilename, bool IsAngled,
+  const FileEntry *File,
+  SrcMgr::CharacteristicKind FileType) override {
+if (!File)
+  return;
+StringRef Filename =
+llvm::sys::path::remove_leading_dotslash(File->getName());
+DepCollector.maybeAddDependency(Filename, /*FromModule=*/false,
+/*IsSystem=*/isSystem(FileType),
+/*IsModuleFile=*/false,
+/*IsMissing=*/false);
   }
+
+  void EndOfMainFile() override { DepCollector.finishedMainFile(Diags); }
 };
 
 struct DepCollectorMMCallbacks : public ModuleMapCallbacks {
@@ -117,9 +140,16 @@
 void DependencyCollector::maybeAddDependency(StringRef Filename, bool FromModule,
 bool IsSystem, bool IsModuleFile,
 bool IsMissing) {
-  if (Seen.insert(Filename).second &&
-  sawDependency(Filename, FromModule, IsSystem, IsModuleFile, IsMissing))
+  if (sawDependency(Filename, FromModule, IsSystem, IsModuleFile, IsMissing))
+addDependency(Filename);
+}
+
+bool DependencyCollector::addDependency(StringRef Filename) {
+  if (Seen.insert(Filename).second) {
 Dependencies.push_back(Filename);
+return true;
+  }
+  return false;
 }
 
 static bool isSpecialFilename(StringRef Filename) {
@@ -138,8 +168,8 @@
 
 DependencyCollector::~DependencyCollector() { }
 void DependencyCollector::attachToPreprocessor(Preprocessor ) {
-  PP.addPPCallbacks(
-  llvm::make_unique(*this, PP.getSourceManager()));
+  PP.addPPCallbacks(llvm::make_unique(
+  *this, PP.getSourceManager(), PP.getDiagnostics()));
   PP.getHeaderSearchInfo().getModuleMap().addModuleMapCallbacks(
   llvm::make_unique(*this));
 }
@@ -147,206 +177,57 @@
   R.addListener(llvm::make_unique(*this));
 }
 
-namespace {
-/// Private implementation for DependencyFileGenerator
-class DFGImpl : public PPCallbacks {
-  std::vector Files;
-  llvm::StringSet<> FilesSet;
-  const Preprocessor *PP;
-  std::string OutputFile;
-  std::vector Targets;
-  bool IncludeSystemHeaders;
-  bool PhonyTarget;
-  bool AddMissingHeaderDeps;
-  bool SeenMissingHeader;
-  bool IncludeModuleFiles;
-  DependencyOutputFormat OutputFormat;
-  unsigned InputFileIndex;
-
-private:
-  bool FileMatchesDepCriteria(const char *Filename,
-  SrcMgr::CharacteristicKind FileType);
-  void OutputDependencyFile();
-
-public:
-  DFGImpl(const Preprocessor *_PP, const DependencyOutputOptions )
-: PP(_PP), OutputFile(Opts.OutputFile), Targets(Opts.Targets),
+DependencyFileGenerator::DependencyFileGenerator(
+const DependencyOutputOptions )
+: OutputFile(Opts.OutputFile), Targets(Opts.Targets),
   IncludeSystemHeaders(Opts.IncludeSystemHeaders),
   

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thank you.  So it sounds like this patch needs to be reverted, and the correct 
version of it will have to insert these intrinsic calls in four places:

- before translating vector arguments to MMX type before calls that pass 
`__m64` arguments,
- after translating MMX parameters to vector type in functions that receive 
`__m64` parameters,
- before translating vector results to MMX type in functions that return 
`__m64`, and
- after translating MMX results to vector type after calls that return `__m64`.

Will that be sufficient to satisfy LLVM?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


Re: r363204 - [clang-scan-deps] initial outline of the tool that runs preprocessor to find

2019-06-18 Thread Alex L via cfe-commits
I committed r363742 with the fix to the test.

Cheers,
Alex

On Tue, 18 Jun 2019 at 10:23, Alex L  wrote:

> Hi Douglas,
>
> Thanks for the heads up! That's definitely a bug.
> I don't think "-c" is needed here. I will adjust this test this morning to
> remove the "-c", and will address the bug later.
>
> Thanks,
> Alex
>
> On Mon, 17 Jun 2019 at 18:02,  wrote:
>
>> Hi Alex,
>>
>> In the test you added here, the json file contains compile commands that
>> includes "-c". Is that really necessary for the test to work properly?
>>
>> The reason I ask is that if you run in a configuration which does not use
>> the integrated assembler, the test fails with an error due to the fact that
>> an external assembler must be invoked:
>>
>> error: unable to handle compilation, expected exactly one compiler job in
>> ' "clang" "-cc1" ...; "/usr/bin/as" "--64" "-I" "Inputs" "-o" "/dev/null"
>>
>> Changing the "-c" to "-S" still shows the test passing when I run it
>> locally, so if the "-c" is not really needed, can it be changed to "-S" to
>> work correctly where the integrated assembler is not the default option?
>>
>> Douglas Yung
>>
>> -Original Message-
>> From: cfe-commits  On Behalf Of Alex
>> Lorenz via cfe-commits
>> Sent: Wednesday, June 12, 2019 14:33
>> To: cfe-commits@lists.llvm.org
>> Subject: r363204 - [clang-scan-deps] initial outline of the tool that
>> runs preprocessor to find
>>
>> Author: arphaman
>> Date: Wed Jun 12 14:32:49 2019
>> New Revision: 363204
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=363204=rev
>> Log:
>> [clang-scan-deps] initial outline of the tool that runs preprocessor to
>> find dependencies over a JSON compilation database
>>
>> This commit introduces an outline for the clang-scan-deps tool that will
>> be used to implement fast dependency discovery phase using implicit modules
>> for explicit module builds.
>>
>> The initial version of the tool works by computing non-modular header
>> dependencies for files in the compilation database without any
>> optimizations (i.e. without source minimization from r362459).
>> The tool spawns a number of worker threads to run the clang compiler
>> workers in parallel.
>>
>> The immediate goal for clang-scan-deps is to create a ClangScanDeps
>> library which will be used to build up this tool to use the source
>> minimization and caching multi-threaded filesystem to implement the
>> optimized non-incremental dependency scanning phase for a non-modular
>> build. This will allow us to do benchmarks and comparisons for performance
>> that the minimization and caching give us
>>
>> Differential Revision: https://reviews.llvm.org/D60233
>>
>> Added:
>> cfe/trunk/test/ClangScanDeps/
>> cfe/trunk/test/ClangScanDeps/Inputs/
>> cfe/trunk/test/ClangScanDeps/Inputs/header.h
>> cfe/trunk/test/ClangScanDeps/Inputs/header2.h
>> cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json
>> cfe/trunk/test/ClangScanDeps/regular_cdb.cpp
>> cfe/trunk/tools/clang-scan-deps/
>> cfe/trunk/tools/clang-scan-deps/CMakeLists.txt
>> cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp
>> Modified:
>> cfe/trunk/test/CMakeLists.txt
>> cfe/trunk/tools/CMakeLists.txt
>>
>> Modified: cfe/trunk/test/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=363204=363203=363204=diff
>>
>> ==
>> --- cfe/trunk/test/CMakeLists.txt (original)
>> +++ cfe/trunk/test/CMakeLists.txt Wed Jun 12 14:32:49 2019
>> @@ -57,6 +57,7 @@ list(APPEND CLANG_TEST_DEPS
>>clang-rename
>>clang-refactor
>>clang-diff
>> +  clang-scan-deps
>>diagtool
>>hmaptool
>>)
>>
>> Added: cfe/trunk/test/ClangScanDeps/Inputs/header.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/header.h?rev=363204=auto
>>
>> ==
>> --- cfe/trunk/test/ClangScanDeps/Inputs/header.h (added)
>> +++ cfe/trunk/test/ClangScanDeps/Inputs/header.h Wed Jun 12 14:32:49
>> +++ 2019
>> @@ -0,0 +1,3 @@
>> +#ifdef INCLUDE_HEADER2
>> +#include "header2.h"
>> +#endif
>>
>> Added: cfe/trunk/test/ClangScanDeps/Inputs/header2.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/header2.h?rev=363204=auto
>>
>> ==
>> --- cfe/trunk/test/ClangScanDeps/Inputs/header2.h (added)
>> +++ cfe/trunk/test/ClangScanDeps/Inputs/header2.h Wed Jun 12 14:32:49
>> +++ 2019
>> @@ -0,0 +1 @@
>> +// header 2.
>>
>> Added: cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json?rev=363204=auto
>>
>> ==
>> --- cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json (added)
>> +++ 

r363742 - [test] NFC, udpate clang-scan-deps tests to not use -c to avoid driver issues when no integrated assembler is present

2019-06-18 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Jun 18 14:36:30 2019
New Revision: 363742

URL: http://llvm.org/viewvc/llvm-project?rev=363742=rev
Log:
[test] NFC, udpate clang-scan-deps tests to not use -c to avoid driver issues 
when no integrated assembler is present

Caught by Douglas Yung.

Modified:
cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json

Modified: cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json?rev=363742=363741=363742=diff
==
--- cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json (original)
+++ cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json Tue Jun 18 14:36:30 
2019
@@ -1,12 +1,12 @@
 [
 {
   "directory": "DIR",
-  "command": "clang -c DIR/regular_cdb.cpp -IInputs -MD -MF DIR/regular_cdb.d",
+  "command": "clang -E -fsyntax-only DIR/regular_cdb.cpp -IInputs -MD -MF 
DIR/regular_cdb.d",
   "file": "DIR/regular_cdb.cpp"
 },
 {
   "directory": "DIR",
-  "command": "clang -c DIR/regular_cdb.cpp -IInputs -D INCLUDE_HEADER2 -MD -MF 
DIR/regular_cdb2.d",
+  "command": "clang -E -fsyntax-only DIR/regular_cdb.cpp -IInputs -D 
INCLUDE_HEADER2 -MD -MF DIR/regular_cdb2.d",
   "file": "DIR/regular_cdb.cpp"
 }
 ]


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


[PATCH] D59253: [AIX][libcxx] AIX system headers need stdint.h and inttypes.h to be re-enterable when macro _STD_TYPES_T is defined

2019-06-18 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59253



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


[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-06-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:250-252
+  // Finish "Frontend" section starting inside clang::ParseAST()
+  if (llvm::timeTraceProfilerEnabled())
+llvm::timeTraceProfilerEnd();

I think i'm missing a point here.
Why do we want to end `"Frontend"` section here,  exclude all this following 
diag/optremark/etc stuff?



Comment at: clang/lib/Parse/ParseAST.cpp:154
   if (HaveLexer) {
-llvm::TimeTraceScope TimeScope("Frontend", StringRef(""));
 P.Initialize();

Why not keep this as `"Lexing"`?



Comment at: clang/lib/Parse/ParseAST.cpp:182
   finalize(S.TemplateInstCallbacks, S);
 
   std::swap(OldCollectStats, S.CollectStats);

I.e. why do we not want to end it here, where the other stats are printed?



Comment at: clang/test/Driver/check-time-trace-sections.py:1
+#!/usr/bin/env python
+

Does some other test already require python?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-18 Thread Mike Klein via Phabricator via cfe-commits
mtklein added a comment.

Ah, thank you for that explanation.  That's got to be exactly what we're 
tripping over in Chromium / Skia.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


[PATCH] D63462: [analyzer] JsonSupport: Escape escapes

2019-06-18 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D63462#1549144 , @NoQ wrote:

> Hmm, this doesn't seem to solve my problem in D62761 
> . Let me write some actual test case so that 
> you knew it's fixed when it's fixed.


Well, I have did the same:

  if (is_dot_node(line)):
  node_id = str_between(line, 'Node', ' [shape=record')
  label = get_label(line)
  label = (label.replace('\\"', '"').replace('', '\\') ...

I believe this is the correct behavior. What I have pointed out is the 
opposite: when we have a unicode character we have to escape it, so it would be 
that `` case. Rewrite that to '\\' is cool and safe.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63462



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Are you saying that using MMX in LLVM requires source-level workarounds in 
> some way, and so we can't lower portable code to use MMX because that code 
> will (reasonably) lack those workarounds?

Yes.

The x86 architecture requires that a program executes an "emms" instruction 
between any MMX instructions, and any x87 instructions.  Otherwise, the x87 
instructions will produce nonsense results.  LLVM, and other compilers, never 
insert emms automatically; this is partially historical, but also because emms 
can be expensive on Intel chips. Instead, the user is expected to call 
_mm_empty() in appropriate places.

To allow users to generate arbitrary vector IR without tripping over this, LLVM 
does not lower vector IR to MMX instructions; instead, it only generates MMX 
instructions for operations using the special type x86_mmx. If any instruction 
or argument has a result or operand of type x86_mmx in LLVM IR, the user must 
explicitly execute emms (@llvm.x86.mmx.emms() in IR, _mm_empty() in C) between 
that instruction, and any code that might use x87 registers.   "Between" isn't 
really sound because emms intrinsic doesn't reliably prevent code motion of 
floating-point operations, but it works well enough in practice.  (See also 
https://bugs.llvm.org/show_bug.cgi?id=35982 .)

On the clang side, without this patch, we only generate code using the x86_mmx 
type in a couple places: _mm_* calls, and inline asm with an MMX operand.  If 
the user does not use either of those, there will never be any values of type 
x86_mmx, so there will never be any MMX instructions, and we avoid the whole 
mess.  64-bit vector operations get lowered to SSE2 instructions instead (or 
scalarized).

This patch introduces a new place where clang will generate the type x86_mmx: 
for call arguments and return values.  This means more places where the user is 
required to write _mm_empty() to get correct behavior.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


[PATCH] D63462: [analyzer] JsonSupport: Escape escapes

2019-06-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, this doesn't seem to solve my problem in D62761 
. Let me write some actual test case so that 
you knew it's fixed when it's fixed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63462



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


r363734 - [OPENMP]Use host's mangling for 128 bit float types on the device.

2019-06-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jun 18 13:29:06 2019
New Revision: 363734

URL: http://llvm.org/viewvc/llvm-project?rev=363734=rev
Log:
[OPENMP]Use host's mangling for 128 bit float types on the device.

Device have to use the same mangling as the host for 128bit float types. 
Otherwise, the codegen for the device is unable to find the parent function 
when it tries to generate the outlined function for the target region and it 
leads to incorrect compilation and crash at the runtime.

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=363734=363733=363734=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Jun 18 13:29:06 2019
@@ -2607,17 +2607,33 @@ void CXXNameMangler::mangleType(const Bu
   case BuiltinType::Double:
 Out << 'd';
 break;
-  case BuiltinType::LongDouble:
-Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
-? 'g'
-: 'e');
+  case BuiltinType::LongDouble: {
+bool UseFloat128Mangling =
+getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
+if (getASTContext().getLangOpts().OpenMP &&
+getASTContext().getLangOpts().OpenMPIsDevice) {
+  UseFloat128Mangling = getASTContext()
+.getAuxTargetInfo()
+->useFloat128ManglingForLongDouble();
+}
+Out << (UseFloat128Mangling ? 'g' : 'e');
 break;
-  case BuiltinType::Float128:
-if (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble())
+  }
+  case BuiltinType::Float128: {
+bool UseFloat128Mangling =
+getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
+if (getASTContext().getLangOpts().OpenMP &&
+getASTContext().getLangOpts().OpenMPIsDevice) {
+  UseFloat128Mangling = getASTContext()
+.getAuxTargetInfo()
+->useFloat128ManglingForLongDouble();
+}
+if (UseFloat128Mangling)
   Out << "U10__float128"; // Match the GCC mangling
 else
   Out << 'g';
 break;
+  }
   case BuiltinType::NullPtr:
 Out << "Dn";
 break;

Modified: cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp?rev=363734=363733=363734=diff
==
--- cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp Tue Jun 18 
13:29:06 2019
@@ -8,13 +8,15 @@
 // CHECK-DAG: [[T:%.+]] = type {{.+}}, fp128,
 // CHECK-DAG: [[T1:%.+]] = type {{.+}}, i128, i128,
 
-struct T {
-  char a;
 #ifndef _ARCH_PPC
-  __float128 f;
+typedef __float128 BIGTYPE;
 #else
-  long double f;
+typedef long double BIGTYPE;
 #endif
+
+struct T {
+  char a;
+  BIGTYPE f;
   char c;
   T() : a(12), f(15) {}
   T +(T ) { f += b.a; return *this;}
@@ -68,3 +70,12 @@ void baz1() {
   T1 t = bar1();
 }
 #pragma omp end declare target
+
+BIGTYPE foo(BIGTYPE f) {
+#pragma omp target map(f)
+  f = 1;
+  return f;
+}
+
+// CHECK: define weak void 
@__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*
+// CHECK: store [[BIGTYPE]] 0xL3FFF, [[BIGTYPE]]* %


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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-06-18 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Andy, can I get you to chime in?


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

https://reviews.llvm.org/D53157



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-06-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/llvm/IR/IntrinsicInst.h:235
+  ebStrict   ///< This corresponds to "fpexcept.strict".
 };
 

kpn wrote:
> rjmccall wrote:
> > Is it okay that `ebUnspecified` and `ebInvalid` overlap here?
> I can think of a couple of alternatives. If they don't overlap then we have 
> to go back and sweep the source to make sure that ebUnspecified is always 
> handled in all cases that currently handle ebInvalid. And in the future 
> nobody is allowed to check in source that doesn't handle both.
> 
> Or, we could drop ebUnspecified, but then ebInvalid would have a valid 
> meaning to the IRBuilder interface. That looks like a bug even if it works 
> properly.
> 
> Generally, adding eb/rmUnspecified but having them overlap the invalid cases 
> seems to me to be the best option.
What is the purpose of `ebInvalid`?  Is this a valid argument to the intrinsic, 
or is it there so that `getExceptionBehavior()` has something to return if it 
doesn't recognize the argument?  For the latter, maybe it would be better to 
just assert that the argument was one of the recognized possibilities; we don't 
generally expect LLVM to silently propagate ill-formed IR.  Or if it's valid to 
not provide exception behavior to the intrinsic, maybe that's the same as 
`ebUnspecified`, or maybe the accessor should return 
`Optional`.


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

https://reviews.llvm.org/D53157



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D59744#1548919 , @efriedma wrote:

> > Now, we could theoretically use a different ABI rule for vectors defined 
> > with Clang-specific extensions, but that seems like it would cause quite a 
> > few problems of its own.
>
> I think we can't reasonably impose this ABI rule on vectors defined with 
> ext_vector_type: that makes it impossible to build portable OpenCL code for 
> 32-bit x86, given the side-effects of introducing any use of the x86_mmx type.


Sorry, I've remained somewhat intentionally ignorant of the issues here.  Are 
you saying that using MMX in LLVM requires source-level workarounds in some 
way, and so we can't lower portable code to use MMX because that code will 
(reasonably) lack those workarounds?  If that's true, then fixing that seems 
like a blocker to landing this patch; it is better to be ABI-non-compliant than 
to produce broken code.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


r363720 - [OPENMP][NVPTX]Correct codegen for 128 bit long double.

2019-06-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jun 18 12:04:27 2019
New Revision: 363720

URL: http://llvm.org/viewvc/llvm-project?rev=363720=rev
Log:
[OPENMP][NVPTX]Correct codegen for 128 bit long double.

If the host uses 128 bit long doubles, the compiler should generate correct 
code for NVPTX devices. If the return type has 128 bit long doubles, in LLVM IR 
this type must be coerced to int array instead.

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=363720=363719=363720=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Jun 18 12:04:27 2019
@@ -6330,7 +6330,9 @@ private:
 static bool isUnsupportedType(ASTContext , QualType T) {
   if (!Context.getTargetInfo().hasFloat16Type() && T->isFloat16Type())
 return true;
-  if (!Context.getTargetInfo().hasFloat128Type() && T->isFloat128Type())
+  if (!Context.getTargetInfo().hasFloat128Type() &&
+  (T->isFloat128Type() ||
+   (T->isRealFloatingType() && Context.getTypeSize(T) == 128)))
 return true;
   if (!Context.getTargetInfo().hasInt128Type() && T->isIntegerType() &&
   Context.getTypeSize(T) > 64)

Modified: cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp?rev=363720=363719=363720=diff
==
--- cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp Tue Jun 18 
12:04:27 2019
@@ -1,6 +1,8 @@
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -aux-triple x86_64-unknown-linux 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | 
FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda 
-aux-triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple 
powerpc64le-unknown-linux-gnu -fopenmp-targets=nvptx64-nvidia-cuda 
-emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple powerpc64le-unknown-linux-gnu -fopenmp-targets=nvptx64-nvidia-cuda 
-aux-triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s
 // expected-no-diagnostics
 
 // CHECK-DAG: [[T:%.+]] = type {{.+}}, fp128,
@@ -8,7 +10,11 @@
 
 struct T {
   char a;
+#ifndef _ARCH_PPC
   __float128 f;
+#else
+  long double f;
+#endif
   char c;
   T() : a(12), f(15) {}
   T +(T ) { f += b.a; return *this;}


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


[PATCH] D63508: make -frewrite-includes handle __has_include wrapped in a macro

2019-06-18 Thread Luboš Luňák via Phabricator via cfe-commits
llunak created this revision.
llunak added reviewers: vsapsai, bkramer.
llunak added a project: clang.
Herald added subscribers: cfe-commits, dexonsmith.

Qt5 has a wrapper macro that makes __has_include simpler to use:
 #ifdef __has_include

1. define QT_HAS_INCLUDE(x) __has_include(x) #else
2. define QT_HAS_INCLUDE(x) 0 #endif #if QT_HAS_INCLUDE()
3. include  #endif

The code handling this so far ignores macros entirely. This patch
handles this specific case in a crude way by checking if an identifier
in #if is a macro whose first token is the checked for macro.


Repository:
  rC Clang

https://reviews.llvm.org/D63508

Files:
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/test/Frontend/rewrite-includes-has-include-macro.c


Index: clang/test/Frontend/rewrite-includes-has-include-macro.c
===
--- /dev/null
+++ clang/test/Frontend/rewrite-includes-has-include-macro.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -E -frewrite-includes %s -o - | FileCheck 
-strict-whitespace %s
+// expected-no-diagnostics
+
+#define MACRO_HAS_INCLUDE(x) __has_include(x)
+#if MACRO_HAS_INCLUDE()
+#endif
+
+// CHECK: #define MACRO_HAS_INCLUDE(x) __has_include(x)
+// CHECK-NEXT: #if (0)/*MACRO_HAS_INCLUDE()*/
+// CHECK-NEXT: #endif
Index: clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
===
--- clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -527,16 +527,28 @@
 PP.LookUpIdentifierInfo(RawToken);
 
   if (RawToken.is(tok::identifier)) {
+// Try to handle macros in the form of
+// '#define QT_HAS_INCLUDE(x) __has_include(x)'.
+const Token *ExpandedToken = 
+if (const MacroInfo *macroInfo =
+PP.getMacroInfo(RawToken.getIdentifierInfo())) {
+  if (macroInfo->getNumTokens() > 0 &&
+  macroInfo->getReplacementToken(0).is(tok::identifier)) {
+ExpandedToken = >getReplacementToken(0);
+  }
+}
+
 bool HasFile;
 SourceLocation Loc = RawToken.getLocation();
 
 // Rewrite __has_include(x)
-if (RawToken.getIdentifierInfo()->isStr("__has_include")) {
+if (ExpandedToken->getIdentifierInfo()->isStr(
+"__has_include")) {
   if (!HandleHasInclude(FileId, RawLex, nullptr, RawToken,
 HasFile))
 continue;
   // Rewrite __has_include_next(x)
-} else if (RawToken.getIdentifierInfo()->isStr(
+} else if (ExpandedToken->getIdentifierInfo()->isStr(
"__has_include_next")) {
   if (DirLookup)
 ++DirLookup;


Index: clang/test/Frontend/rewrite-includes-has-include-macro.c
===
--- /dev/null
+++ clang/test/Frontend/rewrite-includes-has-include-macro.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -E -frewrite-includes %s -o - | FileCheck -strict-whitespace %s
+// expected-no-diagnostics
+
+#define MACRO_HAS_INCLUDE(x) __has_include(x)
+#if MACRO_HAS_INCLUDE()
+#endif
+
+// CHECK: #define MACRO_HAS_INCLUDE(x) __has_include(x)
+// CHECK-NEXT: #if (0)/*MACRO_HAS_INCLUDE()*/
+// CHECK-NEXT: #endif
Index: clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
===
--- clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -527,16 +527,28 @@
 PP.LookUpIdentifierInfo(RawToken);
 
   if (RawToken.is(tok::identifier)) {
+// Try to handle macros in the form of
+// '#define QT_HAS_INCLUDE(x) __has_include(x)'.
+const Token *ExpandedToken = 
+if (const MacroInfo *macroInfo =
+PP.getMacroInfo(RawToken.getIdentifierInfo())) {
+  if (macroInfo->getNumTokens() > 0 &&
+  macroInfo->getReplacementToken(0).is(tok::identifier)) {
+ExpandedToken = >getReplacementToken(0);
+  }
+}
+
 bool HasFile;
 SourceLocation Loc = RawToken.getLocation();
 
 // Rewrite __has_include(x)
-if (RawToken.getIdentifierInfo()->isStr("__has_include")) {
+if (ExpandedToken->getIdentifierInfo()->isStr(
+"__has_include")) {
   if (!HandleHasInclude(FileId, RawLex, nullptr, RawToken,
 HasFile))
 continue;
   // Rewrite __has_include_next(x)

[PATCH] D63490: Script for generating AST JSON dump test cases

2019-06-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks!

I think we can maybe make this a little more convenient to use. For the 
non-JSON `-ast-dump` format, I added `utils/make-ast-dump-check.sh` which can 
be used as (for example):

  $ lit -DFileCheck=$PWD/utils/make-ast-dump-check.sh test/AST/ast-dump-openmp-*

That is: run the tests, and instead of piping their output through `FileCheck`, 
run it through a script that converts the actual output into test expectations. 
That way, the script doesn't need to run `clang` (or know what command-line 
arguments would be used to do so); `lit` does that for you. I don't think that 
approach would be able to provide your `--filters` flag, but maybe that could 
be passed in as part of the `-D`?


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

https://reviews.llvm.org/D63490



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Now, we could theoretically use a different ABI rule for vectors defined with 
> Clang-specific extensions, but that seems like it would cause quite a few 
> problems of its own.

I think we can't reasonably impose this ABI rule on vectors defined with 
ext_vector_type: that makes it impossible to build portable OpenCL code for 
32-bit x86, given the side-effects of introducing any use of the x86_mmx type.  
So that leaves us with two options: make vector_size and ext_vector_type 
incompatible, or revert this patch and intentionally remain ABI-incompatible 
with gcc. (I guess we could theoretically try to separate out a special case 
for OpenCL instead, but that seems even more fragile.)

Being ABI-incompatible is obviously inconvenient if you're writing code using 
MMX types/intrinsics, but using MMX intrinsics is sort of "at your own risk" 
anyway, given neither LLVM nor gcc properly manages the state of the MMX/x87 
register file.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


r363717 - [OPENMP]Use host's long double when compiling the code for device.

2019-06-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jun 18 11:39:26 2019
New Revision: 363717

URL: http://llvm.org/viewvc/llvm-project?rev=363717=rev
Log:
[OPENMP]Use host's long double when compiling the code for device.

The device code must use the same long double type as the host.
Otherwise the code cannot be linked and executed properly. Patch adds
only basic support and checks for supporting of the host long double
double on the device.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=363717=363716=363717=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jun 18 11:39:26 2019
@@ -1915,8 +1915,15 @@ TypeInfo ASTContext::getTypeInfoImpl(con
   Align = Target->getDoubleAlign();
   break;
 case BuiltinType::LongDouble:
-  Width = Target->getLongDoubleWidth();
-  Align = Target->getLongDoubleAlign();
+  if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
+  (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
+   Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
+Width = AuxTarget->getLongDoubleWidth();
+Align = AuxTarget->getLongDoubleAlign();
+  } else {
+Width = Target->getLongDoubleWidth();
+Align = Target->getLongDoubleAlign();
+  }
   break;
 case BuiltinType::Float128:
   if (Target->hasFloat128Type() || !getLangOpts().OpenMP ||

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=363717=363716=363717=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jun 18 11:39:26 2019
@@ -1576,7 +1576,9 @@ void Sema::checkOpenMPDeviceExpr(const E
  "OpenMP device compilation mode is expected.");
   QualType Ty = E->getType();
   if ((Ty->isFloat16Type() && !Context.getTargetInfo().hasFloat16Type()) ||
-  (Ty->isFloat128Type() && !Context.getTargetInfo().hasFloat128Type()) ||
+  ((Ty->isFloat128Type() ||
+(Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128)) &&
+   !Context.getTargetInfo().hasFloat128Type()) ||
   (Ty->isIntegerType() && Context.getTypeSize(Ty) == 128 &&
!Context.getTargetInfo().hasInt128Type()))
 targetDiag(E->getExprLoc(), diag::err_type_unsupported)

Modified: cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp?rev=363717=363716=363717=diff
==
--- cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp Tue Jun 18 
11:39:26 2019
@@ -1,13 +1,24 @@
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-linux 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-host.bc -fsyntax-only
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -fsyntax-only
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-linux-gnu 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple powerpc64le-unknown-linux-gnu -fopenmp-targets=nvptx64-nvidia-cuda 
%s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -fsyntax-only
 
 struct T {
   char a;
+#ifndef _ARCH_PPC
   __float128 f;
+#else
+  long double f;
+#endif
   char c;
   T() : a(12), f(15) {}
-  T +(T ) { f += b.a; return *this;} // expected-error 
{{'__float128' is not supported on this target}}
+#ifndef _ARCH_PPC
+// expected-error@+4 {{'__float128' is not supported on this target}}
+#else
+// expected-error@+2 {{'long double' is not supported on this target}}
+#endif
+  T +(T ) { f += b.a; return *this;}
 };
 
 struct T1 {


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


[PATCH] D63381: Allow copy/move assignment operator to be coroutine as per N4775

2019-06-18 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov accepted this revision.
GorNishanov added a comment.
This revision is now accepted and ready to land.

LGTM! Thank you for the fix.


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

https://reviews.llvm.org/D63381



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


[PATCH] D62437: [clang-tidy] Splits fuchsia-default-arguments

2019-06-18 Thread Julie Hockett via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363712: [clang-tidy] Split fuchsia-default-arguments 
(authored by juliehockett, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62437?vs=204157=205402#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62437

Files:
  clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h
  clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCheck.h
  
clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h
  clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-default-arguments-calls.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-default-arguments-declarations.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-default-arguments.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/fuchsia-default-arguments-calls.cpp
  
clang-tools-extra/trunk/test/clang-tidy/fuchsia-default-arguments-declarations.cpp
  clang-tools-extra/trunk/test/clang-tidy/fuchsia-default-arguments.cpp

Index: clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h
@@ -0,0 +1,34 @@
+//===--- DefaultArgumentsDeclarationsCheck.h - clang-tidy ---*- 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_DEFAULT_ARGUMENTS_DECLARATIONS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_DEFAULT_ARGUMENTS_DECLARATIONS_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace fuchsia {
+
+/// Default parameters are not allowed in declared functions.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/fuchsia-default-parameters.html
+class DefaultArgumentsDeclarationsCheck : public ClangTidyCheck {
+public:
+  DefaultArgumentsDeclarationsCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace fuchsia
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_DEFAULT_ARGUMENTS_DECLARATIONS_H
Index: clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp
@@ -0,0 +1,54 @@
+//===--- DefaultArgumentsDeclarationsCheck.cpp - clang-tidy ---===//
+//
+// 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 "DefaultArgumentsDeclarationsCheck.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace fuchsia {
+
+void DefaultArgumentsDeclarationsCheck::registerMatchers(MatchFinder *Finder) {
+  // Declaring default parameters is disallowed.
+  Finder->addMatcher(parmVarDecl(hasDefaultArgument()).bind("decl"), this);
+}
+
+void DefaultArgumentsDeclarationsCheck::check(
+const MatchFinder::MatchResult ) {
+  const auto *D = Result.Nodes.getNodeAs("decl");
+  if (!D)
+return;
+
+  SourceRange DefaultArgRange = D->getDefaultArgRange();
+
+  if (DefaultArgRange.getEnd() != D->getEndLoc())
+return;
+
+  if (DefaultArgRange.getBegin().isMacroID()) {
+diag(D->getBeginLoc(),
+ "declaring a parameter with a default argument is disallowed");
+return;
+  }
+
+  SourceLocation StartLocation =
+  

[PATCH] D63361: Pretend NRVO variables are references so they can be found by debug info

2019-06-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Thanks, this addresses my concern!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63361



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


[clang-tools-extra] r363712 - [clang-tidy] Split fuchsia-default-arguments

2019-06-18 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Tue Jun 18 11:07:33 2019
New Revision: 363712

URL: http://llvm.org/viewvc/llvm-project?rev=363712=rev
Log:
[clang-tidy] Split fuchsia-default-arguments

Splits fuchsia-default-arguments check into two checks. 
fuchsia-default-arguments-calls warns if a function or method is called with 
default arguments. fuchsia-default-arguments-declarations warns if a function 
or method is declared with default parameters.

Committed on behalf of @diegoast (Diego Astiazarán).

Resolves b38051.

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

Added:
clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp
clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h

clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.cpp

clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsDeclarationsCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-default-arguments-calls.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-default-arguments-declarations.rst
clang-tools-extra/trunk/test/clang-tidy/fuchsia-default-arguments-calls.cpp

clang-tools-extra/trunk/test/clang-tidy/fuchsia-default-arguments-declarations.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCheck.cpp
clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-default-arguments.rst
clang-tools-extra/trunk/test/clang-tidy/fuchsia-default-arguments.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt?rev=363712=363711=363712=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt Tue Jun 18 
11:07:33 2019
@@ -1,7 +1,8 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyFuchsiaModule
-  DefaultArgumentsCheck.cpp
+  DefaultArgumentsCallsCheck.cpp
+  DefaultArgumentsDeclarationsCheck.cpp
   FuchsiaTidyModule.cpp
   MultipleInheritanceCheck.cpp
   OverloadedOperatorCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp?rev=363712=auto
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.cpp 
Tue Jun 18 11:07:33 2019
@@ -0,0 +1,35 @@
+//===--- DefaultArgumentsCallsCheck.cpp - 
clang-tidy---===//
+//
+// 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 "DefaultArgumentsCallsCheck.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace fuchsia {
+
+void DefaultArgumentsCallsCheck::registerMatchers(MatchFinder *Finder) {
+  // Calling a function which uses default arguments is disallowed.
+  Finder->addMatcher(cxxDefaultArgExpr().bind("stmt"), this);
+}
+
+void DefaultArgumentsCallsCheck::check(const MatchFinder::MatchResult ) 
{
+  const auto *S = Result.Nodes.getNodeAs("stmt");
+  if (!S)
+return;
+
+  diag(S->getUsedLocation(),
+   "calling a function that uses a default argument is disallowed");
+  diag(S->getParam()->getBeginLoc(), "default parameter was declared here",
+   DiagnosticIDs::Note);
+}
+
+} // namespace fuchsia
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h?rev=363712=auto
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h 
(added)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/DefaultArgumentsCallsCheck.h Tue 
Jun 18 11:07:33 2019
@@ -0,0 +1,34 @@
+//===--- DefaultArgumentsCallsCheck.h - clang-tidy --*- 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
+//

[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-06-18 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked an inline comment as done.
kpn added inline comments.



Comment at: include/llvm/IR/IntrinsicInst.h:235
+  ebStrict   ///< This corresponds to "fpexcept.strict".
 };
 

rjmccall wrote:
> Is it okay that `ebUnspecified` and `ebInvalid` overlap here?
I can think of a couple of alternatives. If they don't overlap then we have to 
go back and sweep the source to make sure that ebUnspecified is always handled 
in all cases that currently handle ebInvalid. And in the future nobody is 
allowed to check in source that doesn't handle both.

Or, we could drop ebUnspecified, but then ebInvalid would have a valid meaning 
to the IRBuilder interface. That looks like a bug even if it works properly.

Generally, adding eb/rmUnspecified but having them overlap the invalid cases 
seems to me to be the best option.


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

https://reviews.llvm.org/D53157



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


r363709 - Add test cases for dumping AST function decl nodes to JSON; NFC.

2019-06-18 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Jun 18 10:56:50 2019
New Revision: 363709

URL: http://llvm.org/viewvc/llvm-project?rev=363709=rev
Log:
Add test cases for dumping AST function decl nodes to JSON; NFC.

Added:
cfe/trunk/test/AST/ast-dump-funcs-json.cpp

Added: cfe/trunk/test/AST/ast-dump-funcs-json.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-funcs-json.cpp?rev=363709=auto
==
--- cfe/trunk/test/AST/ast-dump-funcs-json.cpp (added)
+++ cfe/trunk/test/AST/ast-dump-funcs-json.cpp Tue Jun 18 10:56:50 2019
@@ -0,0 +1,1126 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump=json 
-ast-dump-filter Test %s | FileCheck %s
+
+struct S {
+  void Test1();
+  void Test2() const;
+  void Test3() volatile;
+  void Test4() &;
+  void Test5() &&;
+  virtual void Test6(float, int = 12);
+  virtual void Test7() = 0;
+};
+
+struct T : S { // T is not referenced, but S is
+  void Test6(float, int = 100) override;
+};
+
+struct U {
+  void Test1();
+};
+void U::Test1() {} // parent
+
+void Test1();
+void Test2(void);
+void Test3(int a, int b);
+void Test4(int a, int b = 12);
+constexpr void Test5(void);
+static void Test6(void);
+extern void Test7(void);
+inline void Test8(void);
+void Test9(void) noexcept;
+void Test10(void) noexcept(false);
+void Test11(void) noexcept(1);
+
+template 
+T Test12(T&);
+
+void Test13(int) {}
+void Test14(int, ...) {}
+
+int main() {
+  Test1(); // Causes this to be marked 'used'
+}
+
+
+// CHECK:  "kind": "CXXMethodDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 8,
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 4
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 3,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 4
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 14,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 4
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "Test1",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "void ()"
+// CHECK-NEXT:  }
+// CHECK-NEXT: }
+
+
+// CHECK:  "kind": "CXXMethodDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 8,
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 5
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 3,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 5
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 16,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 5
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "Test2",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "void () const"
+// CHECK-NEXT:  }
+// CHECK-NEXT: }
+
+
+// CHECK:  "kind": "CXXMethodDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 8,
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 6
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 3,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 6
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 16,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 6
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "Test3",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "void () volatile"
+// CHECK-NEXT:  }
+// CHECK-NEXT: }
+
+
+// CHECK:  "kind": "CXXMethodDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 8,
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 7
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 3,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 7
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 16,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 7
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "Test4",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "void () &"
+// CHECK-NEXT:  }
+// CHECK-NEXT: }
+
+
+// CHECK:  "kind": "CXXMethodDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 8,
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 8
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 3,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 8
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 16,
+// CHECK-NEXT:"file": "{{.*}}",
+// CHECK-NEXT:"line": 8
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "Test5",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "void () &&"
+// CHECK-NEXT:  }
+// CHECK-NEXT: }
+
+
+// CHECK:  "kind": "CXXMethodDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 16,
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 9
+// CHECK-NEXT:  },

[PATCH] D63503: cmake: Add CLANG_LINK_CLANG_DYLIB option

2019-06-18 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
tstellar added reviewers: mgorny, beanz, smeenai, phosek, sylvestre.ledru.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

Setting CLANG_LINK_CLANG_DYLIB=ON causes clang tools to link against
libclang_shared.so instead of the individual component libraries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63503

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  clang/examples/AnnotateFunctions/CMakeLists.txt
  clang/examples/PrintFunctionNames/CMakeLists.txt
  clang/examples/clang-interpreter/CMakeLists.txt
  clang/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
  clang/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
  clang/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
  clang/tools/arcmt-test/CMakeLists.txt
  clang/tools/clang-check/CMakeLists.txt
  clang/tools/clang-diff/CMakeLists.txt
  clang/tools/clang-extdef-mapping/CMakeLists.txt
  clang/tools/clang-format/CMakeLists.txt
  clang/tools/clang-import-test/CMakeLists.txt
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-refactor/CMakeLists.txt
  clang/tools/clang-rename/CMakeLists.txt
  clang/tools/clang-scan-deps/CMakeLists.txt
  clang/tools/diagtool/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/ASTMatchers/CMakeLists.txt
  clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
  clang/unittests/Analysis/CMakeLists.txt
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/CodeGen/CMakeLists.txt
  clang/unittests/CrossTU/CMakeLists.txt
  clang/unittests/Driver/CMakeLists.txt
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Index/CMakeLists.txt
  clang/unittests/Lex/CMakeLists.txt
  clang/unittests/Rename/CMakeLists.txt
  clang/unittests/Rewrite/CMakeLists.txt
  clang/unittests/Sema/CMakeLists.txt
  clang/unittests/Serialization/CMakeLists.txt
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/Syntax/CMakeLists.txt

Index: clang/unittests/Tooling/Syntax/CMakeLists.txt
===
--- clang/unittests/Tooling/Syntax/CMakeLists.txt
+++ clang/unittests/Tooling/Syntax/CMakeLists.txt
@@ -6,7 +6,7 @@
   TokensTest.cpp
 )
 
-target_link_libraries(SyntaxTests
+clang_target_link_libraries(SyntaxTests
   PRIVATE
   clangAST
   clangBasic
@@ -15,5 +15,9 @@
   clangSerialization
   clangTooling
   clangToolingSyntax
-  LLVMTestingSupport
   )
+
+target_link_libraries(SyntaxTests
+  PRIVATE
+  LLVMTestingSupport
+)
Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -56,7 +56,7 @@
   TransformerTest.cpp
   )
 
-target_link_libraries(ToolingTests
+clang_target_link_libraries(ToolingTests
   PRIVATE
   clangAST
   clangASTMatchers
@@ -70,8 +70,11 @@
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactoring
-  LLVMTestingSupport
   )
 
+target_link_libraries(ToolingTests
+  PRIVATE
+  LLVMTestingSupport
+)
 
 add_subdirectory(Syntax)
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -9,7 +9,7 @@
   SymbolReaperTest.cpp
   )
 
-target_link_libraries(StaticAnalysisTests
+clang_target_link_libraries(StaticAnalysisTests
   PRIVATE
   clangBasic
   clangAnalysis
Index: clang/unittests/Serialization/CMakeLists.txt
===
--- clang/unittests/Serialization/CMakeLists.txt
+++ clang/unittests/Serialization/CMakeLists.txt
@@ -7,7 +7,7 @@
   InMemoryModuleCacheTest.cpp
   )
 
-target_link_libraries(SerializationTests
+clang_target_link_libraries(SerializationTests
   PRIVATE
   clangAST
   clangBasic
Index: clang/unittests/Sema/CMakeLists.txt
===
--- clang/unittests/Sema/CMakeLists.txt
+++ clang/unittests/Sema/CMakeLists.txt
@@ -7,7 +7,7 @@
   CodeCompleteTest.cpp
   )
 
-target_link_libraries(SemaTests
+clang_target_link_libraries(SemaTests
   PRIVATE
   clangAST
   clangBasic
@@ -16,5 +16,9 @@
   clangSema
   clangSerialization
   clangTooling
-  LLVMTestingSupport
   )
+
+target_link_libraries(SemaTests
+  PRIVATE
+  LLVMTestingSupport
+)
Index: clang/unittests/Rewrite/CMakeLists.txt
===
--- clang/unittests/Rewrite/CMakeLists.txt
+++ clang/unittests/Rewrite/CMakeLists.txt
@@ -5,7 +5,7 @@
 add_clang_unittest(RewriteTests
   RewriteBufferTest.cpp
   )
-target_link_libraries(RewriteTests
+clang_target_link_libraries(RewriteTests
   PRIVATE
   clangRewrite
   )
Index: 

[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-06-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/llvm/IR/IntrinsicInst.h:235
+  ebStrict   ///< This corresponds to "fpexcept.strict".
 };
 

Is it okay that `ebUnspecified` and `ebInvalid` overlap here?



Comment at: include/llvm/IR/IntrinsicInst.h:245
+static ExceptionBehavior StrToExceptionBehavior(StringRef);
+static StringRef ExceptionBehaviorToStr(ExceptionBehavior);
+

You should document the behavior of the `StrTo...` functions when the string is 
unexpected and the `...ToStr` functions when the enum is invalid/unspecified.


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

https://reviews.llvm.org/D53157



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D59744#1548540 , @mtklein wrote:

> Hey folks, I'm the Skia point of contact on this, and "luckily" the person 
> who wrote all the code that got us into this mess.  Let me cross post a 
> couple questions I've had from the Chromium bug over here where folks might 
> know the answer...
>
> Now that Clang's decided to match GCC's behavior of using mm0 to pass around 
> 8-byte vectors on x86-32, is there any way to use 8-byte vector types safely 
> any more?  I don't really have the full context of this Clang change, but is 
> it maybe a good idea applied to too many types?  I notice the change mentions 
> __m64, but here I'm using uint16_t ext_vector_type(4) exclusively, never 
> __m64 or even an 8x8 vector... can we just squint and say u16x4 and __m64 
> aren't the same, passing __m64 according to the ABI but vector extensions 
> however we were doing it before?


`__m64` is of course defined using the compiler's vector extensions.  More 
importantly, GCC also has those vector extensions (or at least some of them), 
and my understanding is that GCC is interpreting the ABI's  `__m64` to mean 
"all 8-byte vectors" (which seems quite reasonable to me), and that's what 
Clang needs to stay compatible with on systems where GCC is the system compiler.

Now, we could theoretically use a different ABI rule for vectors defined with 
Clang-specific extensions, but that seems like it would cause quite a few 
problems of its own.

> In short, should working with 4x u16 be safe on x86-32 and there's a bug / 
> undefined behavior in my code leading to this  mm0/st0 clobber, or is this 
> just actually not really spec'd to work?

It's always possible that there's a bug in the compiler, but the most likely 
thing is that you have assembly code that's not obeying the ABI in some way.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


Re: r363204 - [clang-scan-deps] initial outline of the tool that runs preprocessor to find

2019-06-18 Thread Alex L via cfe-commits
Hi Douglas,

Thanks for the heads up! That's definitely a bug.
I don't think "-c" is needed here. I will adjust this test this morning to
remove the "-c", and will address the bug later.

Thanks,
Alex

On Mon, 17 Jun 2019 at 18:02,  wrote:

> Hi Alex,
>
> In the test you added here, the json file contains compile commands that
> includes "-c". Is that really necessary for the test to work properly?
>
> The reason I ask is that if you run in a configuration which does not use
> the integrated assembler, the test fails with an error due to the fact that
> an external assembler must be invoked:
>
> error: unable to handle compilation, expected exactly one compiler job in
> ' "clang" "-cc1" ...; "/usr/bin/as" "--64" "-I" "Inputs" "-o" "/dev/null"
>
> Changing the "-c" to "-S" still shows the test passing when I run it
> locally, so if the "-c" is not really needed, can it be changed to "-S" to
> work correctly where the integrated assembler is not the default option?
>
> Douglas Yung
>
> -Original Message-
> From: cfe-commits  On Behalf Of Alex
> Lorenz via cfe-commits
> Sent: Wednesday, June 12, 2019 14:33
> To: cfe-commits@lists.llvm.org
> Subject: r363204 - [clang-scan-deps] initial outline of the tool that runs
> preprocessor to find
>
> Author: arphaman
> Date: Wed Jun 12 14:32:49 2019
> New Revision: 363204
>
> URL: http://llvm.org/viewvc/llvm-project?rev=363204=rev
> Log:
> [clang-scan-deps] initial outline of the tool that runs preprocessor to
> find dependencies over a JSON compilation database
>
> This commit introduces an outline for the clang-scan-deps tool that will
> be used to implement fast dependency discovery phase using implicit modules
> for explicit module builds.
>
> The initial version of the tool works by computing non-modular header
> dependencies for files in the compilation database without any
> optimizations (i.e. without source minimization from r362459).
> The tool spawns a number of worker threads to run the clang compiler
> workers in parallel.
>
> The immediate goal for clang-scan-deps is to create a ClangScanDeps
> library which will be used to build up this tool to use the source
> minimization and caching multi-threaded filesystem to implement the
> optimized non-incremental dependency scanning phase for a non-modular
> build. This will allow us to do benchmarks and comparisons for performance
> that the minimization and caching give us
>
> Differential Revision: https://reviews.llvm.org/D60233
>
> Added:
> cfe/trunk/test/ClangScanDeps/
> cfe/trunk/test/ClangScanDeps/Inputs/
> cfe/trunk/test/ClangScanDeps/Inputs/header.h
> cfe/trunk/test/ClangScanDeps/Inputs/header2.h
> cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json
> cfe/trunk/test/ClangScanDeps/regular_cdb.cpp
> cfe/trunk/tools/clang-scan-deps/
> cfe/trunk/tools/clang-scan-deps/CMakeLists.txt
> cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp
> Modified:
> cfe/trunk/test/CMakeLists.txt
> cfe/trunk/tools/CMakeLists.txt
>
> Modified: cfe/trunk/test/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=363204=363203=363204=diff
>
> ==
> --- cfe/trunk/test/CMakeLists.txt (original)
> +++ cfe/trunk/test/CMakeLists.txt Wed Jun 12 14:32:49 2019
> @@ -57,6 +57,7 @@ list(APPEND CLANG_TEST_DEPS
>clang-rename
>clang-refactor
>clang-diff
> +  clang-scan-deps
>diagtool
>hmaptool
>)
>
> Added: cfe/trunk/test/ClangScanDeps/Inputs/header.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/header.h?rev=363204=auto
>
> ==
> --- cfe/trunk/test/ClangScanDeps/Inputs/header.h (added)
> +++ cfe/trunk/test/ClangScanDeps/Inputs/header.h Wed Jun 12 14:32:49
> +++ 2019
> @@ -0,0 +1,3 @@
> +#ifdef INCLUDE_HEADER2
> +#include "header2.h"
> +#endif
>
> Added: cfe/trunk/test/ClangScanDeps/Inputs/header2.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/header2.h?rev=363204=auto
>
> ==
> --- cfe/trunk/test/ClangScanDeps/Inputs/header2.h (added)
> +++ cfe/trunk/test/ClangScanDeps/Inputs/header2.h Wed Jun 12 14:32:49
> +++ 2019
> @@ -0,0 +1 @@
> +// header 2.
>
> Added: cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json?rev=363204=auto
>
> ==
> --- cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json (added)
> +++ cfe/trunk/test/ClangScanDeps/Inputs/regular_cdb.json Wed Jun 12
> +++ 14:32:49 2019
> @@ -0,0 +1,12 @@
> +[
> +{
> +  "directory": "DIR",
> +  "command": "clang -c DIR/regular_cdb.cpp -IInputs -MD -MF
> +DIR/regular_cdb.d",
> +  "file": "DIR/regular_cdb.cpp"
> +},

[PATCH] D62956: [clangd] Collect tokens of main files when building the AST

2019-06-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D62956#1547826 , @sammccall wrote:

> Can we add a test using TestTU that does a very basic verification of 
> expanded/spelled tokens (first after preamble, last token in file)?


Done. Will land this tomorrow, want to run it over all of LLVM first to give 
the token-building code some coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62956



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


[PATCH] D62956: [clangd] Collect tokens of main files when building the AST

2019-06-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 205387.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Rename tokens() to getTokens() for consistency with the rest of ParsedAST.
- Update comments.
- Add a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62956

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdUnit.cpp
  clang-tools-extra/clangd/ClangdUnit.h
  clang-tools-extra/clangd/tool/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp
@@ -10,6 +10,8 @@
 #include "ClangdUnit.h"
 #include "SourceCode.h"
 #include "TestTU.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -81,6 +83,37 @@
   EXPECT_THAT(AST.getLocalTopLevelDecls(), ElementsAre(DeclNamed("main")));
 }
 
+TEST(ClangdUnitTest, TokensAfterPreamble) {
+  TestTU TU;
+  TU.AdditionalFiles["foo.h"] = R"(
+int foo();
+  )";
+  TU.Code = R"cpp(
+  #include "foo.h"
+  first_token;
+  void test() {
+  }
+  last_token
+)cpp";
+  auto AST = TU.build();
+  const syntax::TokenBuffer  = AST.getTokens();
+  const auto  = AST.getSourceManager();
+
+  ASSERT_GT(T.expandedTokens().size(), 2u);
+  // First token after preamble is 'void'.
+  EXPECT_EQ(T.expandedTokens().front().text(SM), "first_token");
+  // Last token is always 'eof'.
+  EXPECT_EQ(T.expandedTokens().back().kind(), tok::eof);
+  // Check the token right before 'eof'.
+  EXPECT_EQ(T.expandedTokens().drop_back().back().text(SM), "last_token");
+
+  // The spelled tokens for the main file should have everything.
+  auto Spelled = T.spelledTokens(SM.getMainFileID());
+  ASSERT_FALSE(Spelled.empty());
+  EXPECT_EQ(Spelled.front().kind(), tok::hash);
+  EXPECT_EQ(Spelled.back().text(SM), "last_token");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -87,6 +87,7 @@
   clangTooling
   clangToolingCore
   clangToolingInclusions
+  clangToolingSyntax
   LLVMSupport
   LLVMTestingSupport
   )
Index: clang-tools-extra/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -26,5 +26,6 @@
   clangSema
   clangTooling
   clangToolingCore
+  clangToolingSyntax
   ${CLANGD_XPC_LIBS}
   )
Index: clang-tools-extra/clangd/ClangdUnit.h
===
--- clang-tools-extra/clangd/ClangdUnit.h
+++ clang-tools-extra/clangd/ClangdUnit.h
@@ -24,6 +24,7 @@
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include 
 #include 
 #include 
@@ -115,10 +116,14 @@
   const IncludeStructure () const;
   const CanonicalIncludes () const;
 
+  /// Tokens recorded while parsing the main file.
+  /// (!) does not have tokens from the preamble.
+  const syntax::TokenBuffer () const { return Tokens; }
+
 private:
   ParsedAST(std::shared_ptr Preamble,
 std::unique_ptr Clang,
-std::unique_ptr Action,
+std::unique_ptr Action, syntax::TokenBuffer Tokens,
 std::vector LocalTopLevelDecls, std::vector Diags,
 IncludeStructure Includes, CanonicalIncludes CanonIncludes);
 
@@ -132,6 +137,11 @@
   // FrontendAction.EndSourceFile).
   std::unique_ptr Clang;
   std::unique_ptr Action;
+  /// Tokens recorded after the preamble finished.
+  ///   - Includes all spelled tokens for the main file.
+  ///   - Includes expanded tokens produced **after** preabmle.
+  ///   - Does not have spelled or expanded tokens for files from preamble.
+  syntax::TokenBuffer Tokens;
 
   // Data, stored after parsing.
   std::vector Diags;
Index: clang-tools-extra/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/clangd/ClangdUnit.cpp
+++ clang-tools-extra/clangd/ClangdUnit.cpp
@@ -36,6 +36,7 @@
 #include "clang/Serialization/ASTWriter.h"
 #include "clang/Serialization/PCHContainerOperations.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include 

[PATCH] D63361: Pretend NRVO variables are references so they can be found by debug info

2019-06-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This needs two unit tests:

- A clang test at `clang/test/CodeGenCXX/debug-info-nrvo.cpp` similar to other 
debug-info-* tests there. This test should have a second RUN line and extra 
checks for -fno-elide-constructors.
- An LLVM test at `llvm/test/DebugInfo/COFF/nrvo.ll` to show that we handle 
dbg.declare + deref

Truly, we should also test the inalloca case.




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3946
+  // the address of the variable.
+  if (VD->isNRVOVariable())
+Expr.push_back(llvm::dwarf::DW_OP_deref);

I think we should check for `getLangOpts().ElideConstructors` here, and check 
that the debug info is correct (no deref) in that mode.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:908
 --EI;
 llvm::Value *Addr = Builder.CreateStructGEP(nullptr, &*EI, Idx);
 Addr = Builder.CreateAlignedLoad(Addr, getPointerAlign(), "agg.result");

What I had in mind was to use this GEP as the ReturnValuePointer here. The 
inalloca parameter is also a pointer to stack memory, and a GEP is an offset, 
so it should end up being handled like a static alloca.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63361



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


[PATCH] D62635: Add enums as global variables in the IR metadata.

2019-06-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D62635#1548721 , @rnk wrote:

> In D62635#1548648 , @dblaikie wrote:
>
> > In D62635#1548157 , @rnk wrote:
> >
> > > We did things this way to track which **enumerators** were used, not 
> > > which enums were used. Size data showed it was worth doing (6%). The 
> > > existing format doesn't support tracking usage of individual enumerators, 
> > > so we pretended they were const integers to avoid changing the schema.
> >
> >
> > Ah - describing all the enumerators in any emitted enum would be too many 
> > bits/too much size in output?
>
>
> Yes, that's what @akhuang tried and measured against to come up with the 6% 
> number.


Ah, OK - unused enumerators in used enumerations, rather than all unused 
enumerators in all enumerations unused or used... I'm with you now. Thanks!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62635



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


[PATCH] D62635: Add enums as global variables in the IR metadata.

2019-06-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D62635#1548648 , @dblaikie wrote:

> In D62635#1548157 , @rnk wrote:
>
> > We did things this way to track which **enumerators** were used, not which 
> > enums were used. Size data showed it was worth doing (6%). The existing 
> > format doesn't support tracking usage of individual enumerators, so we 
> > pretended they were const integers to avoid changing the schema.
>
>
> Ah - describing all the enumerators in any emitted enum would be too many 
> bits/too much size in output?


Yes, that's what @akhuang tried and measured against to come up with the 6% 
number.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62635



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


[PATCH] D63361: Pretend NRVO variables are references so they can be found by debug info

2019-06-18 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 205385.
akhuang added a comment.

- add semicolon


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63361

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  debuginfo-tests/nrvo-string.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1142,9 +1142,15 @@
 // If the variable has an attached offset expression, extract it.
 // FIXME: Try to handle DW_OP_deref as well.
 int64_t ExprOffset = 0;
-if (VI.Expr)
-  if (!VI.Expr->extractIfOffset(ExprOffset))
+bool Deref = false;
+if (VI.Expr) {
+  // If there is one DW_OP_deref element, use offset of 0 and keep going.
+  if (VI.Expr->getNumElements() == 1 &&
+  VI.Expr->getElement(0) == llvm::dwarf::DW_OP_deref)
+Deref = true;
+  else if (!VI.Expr->extractIfOffset(ExprOffset))
 continue;
+}
 
 // Get the frame register used and the offset.
 unsigned FrameReg = 0;
@@ -1154,6 +1160,7 @@
 // Calculate the label ranges.
 LocalVarDefRange DefRange =
 createDefRangeMem(CVReg, FrameOffset + ExprOffset);
+
 for (const InsnRange  : Scope->getRanges()) {
   const MCSymbol *Begin = getLabelBeforeInsn(Range.first);
   const MCSymbol *End = getLabelAfterInsn(Range.second);
@@ -1164,6 +1171,9 @@
 LocalVariable Var;
 Var.DIVar = VI.Var;
 Var.DefRanges.emplace_back(std::move(DefRange));
+if (Deref)
+  Var.UseReferenceType = true;
+
 recordLocalVariable(std::move(Var), Scope);
   }
 }
Index: debuginfo-tests/nrvo-string.cpp
===
--- debuginfo-tests/nrvo-string.cpp
+++ debuginfo-tests/nrvo-string.cpp
@@ -17,11 +17,32 @@
 string get_string() {
   string unused;
   string result = 3;
-// DEBUGGER: break 21
+  // DEBUGGER: break 21
   return result;
 }
-int main() { get_string(); }
+void some_function(int) {}
+struct string2 {
+  string2() = default;
+  string2(string2 &) { i = other.i; }
+  int i;
+};
+string2 get_string2() {
+  string2 result;
+  result.i = 5;
+  some_function(result.i);
+  // Test that the debugger can get the value of result after another
+  // function is called.
+  // DEBUGGER: break 35
+  return result;
+}
+int main() {
+  get_string();
+  get_string2();
+}
 
 // DEBUGGER: r
 // DEBUGGER: print result.i
 // CHECK:  = 3
+// DEBUGGER: c
+// DEBUGGER: print result.i
+// CHECK:  = 5
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -327,6 +327,10 @@
   /// value. This is invalid iff the function has no return value.
   Address ReturnValue = Address::invalid();
 
+  /// ReturnValuePointer - The temporary alloca to hold a pointer to sret.
+  /// This is invalid if sret is not in use.
+  Address ReturnValuePointer = Address::invalid();
+
   /// Return true if a label was seen in the current scope.
   bool hasLabelBeenSeenInCurrentScope() const {
 if (CurLexicalScope)
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -895,6 +895,10 @@
 if (CurFnInfo->getReturnInfo().isSRetAfterThis())
   ++AI;
 ReturnValue = Address(&*AI, CurFnInfo->getReturnInfo().getIndirectAlign());
+ReturnValuePointer = CreateDefaultAlignTempAlloca(Int8PtrTy, "result.ptr");
+Builder.CreateStore(Builder.CreatePointerBitCastOrAddrSpaceCast(
+ReturnValue.getPointer(), Int8PtrTy),
+ReturnValuePointer);
   } else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::InAlloca &&
  !hasScalarEvaluationKind(CurFnInfo->getReturnType())) {
 // Load the sret pointer from the argument struct and return into that.
@@ -904,6 +908,10 @@
 llvm::Value *Addr = Builder.CreateStructGEP(nullptr, &*EI, Idx);
 Addr = Builder.CreateAlignedLoad(Addr, getPointerAlign(), "agg.result");
 ReturnValue = Address(Addr, getNaturalTypeAlignment(RetTy));
+ReturnValuePointer = CreateDefaultAlignTempAlloca(Int8PtrTy, "result.ptr");
+Builder.CreateStore(Builder.CreatePointerBitCastOrAddrSpaceCast(
+ReturnValue.getPointer(), Int8PtrTy),
+ReturnValuePointer);
   } else {
 ReturnValue = CreateIRTemp(RetTy, "retval");
 
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp

[PATCH] D63361: Pretend NRVO variables are references so they can be found by debug info

2019-06-18 Thread Amy Huang via Phabricator via cfe-commits
akhuang added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:1145-1149
+bool Deref = false;
+if (VI.Expr) {
+  if (!VI.Expr->extractIfOffset(ExprOffset, Deref))
 continue;
+}

rnk wrote:
> I see. I thought this code was using the stuff I added in 
> `DbgVariableLocation::extractFromMachineInstruction`. Hm.
> 
> In practice, do you actually see DIExpression offsets here? I think maybe we 
> should just special case a single DW_OP_deref expression, since that's what 
> we get at O0.
That should work


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63361



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


[PATCH] D63161: Devirtualize destructor of final class.

2019-06-18 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 205381.
yamauchi added a comment.

Updated.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63161

Files:
  lib/CodeGen/CGExprCXX.cpp
  test/CodeGenCXX/devirtualize-dtor-final.cpp


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void@_ZN5Test11DD1Ev
+delete p;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,33 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (getCXXRecord(Base) == DevirtualizedClass) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual call. FIXME: handle the case where it is
+// devirtualized to the derived type (the type of the inner
+// expression) as in EmitCXXMemberOrOperatorMemberCallExpr.
+UseVirtualCall = true;
+  }
+}
+if (UseVirtualCall) {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }


Index: test/CodeGenCXX/devirtualize-dtor-final.cpp
===
--- /dev/null
+++ test/CodeGenCXX/devirtualize-dtor-final.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - | FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void@_ZN5Test11DD1Ev
+delete p;
+  }
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -1865,9 +1865,33 @@
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (getCXXRecord(Base) == DevirtualizedClass) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual 

[PATCH] D63361: Pretend NRVO variables are references so they can be found by debug info

2019-06-18 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 205382.
akhuang marked 2 inline comments as done.
akhuang added a comment.

Now creates a pointer to the return location in the function prolog, whenever 
sret is being used.

Also addressed some other comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63361

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  debuginfo-tests/nrvo-string.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1142,9 +1142,15 @@
 // If the variable has an attached offset expression, extract it.
 // FIXME: Try to handle DW_OP_deref as well.
 int64_t ExprOffset = 0;
-if (VI.Expr)
-  if (!VI.Expr->extractIfOffset(ExprOffset))
+bool Deref = false;
+if (VI.Expr) {
+  // If there is one DW_OP_deref element, use offset of 0 and keep going.
+  if (VI.Expr->getNumElements() == 1 &&
+  VI.Expr->getElement(0) == llvm::dwarf::DW_OP_deref)
+Deref = true;
+  else if (!VI.Expr->extractIfOffset(ExprOffset))
 continue;
+}
 
 // Get the frame register used and the offset.
 unsigned FrameReg = 0;
@@ -1154,6 +1160,7 @@
 // Calculate the label ranges.
 LocalVarDefRange DefRange =
 createDefRangeMem(CVReg, FrameOffset + ExprOffset);
+
 for (const InsnRange  : Scope->getRanges()) {
   const MCSymbol *Begin = getLabelBeforeInsn(Range.first);
   const MCSymbol *End = getLabelAfterInsn(Range.second);
@@ -1164,6 +1171,9 @@
 LocalVariable Var;
 Var.DIVar = VI.Var;
 Var.DefRanges.emplace_back(std::move(DefRange));
+if (Deref)
+  Var.UseReferenceType = true;
+
 recordLocalVariable(std::move(Var), Scope);
   }
 }
Index: debuginfo-tests/nrvo-string.cpp
===
--- debuginfo-tests/nrvo-string.cpp
+++ debuginfo-tests/nrvo-string.cpp
@@ -17,11 +17,31 @@
 string get_string() {
   string unused;
   string result = 3;
-// DEBUGGER: break 21
+  // DEBUGGER: break 21
   return result;
 }
-int main() { get_string(); }
+void some_function(int) {}
+struct string2 {
+  string2() = default;
+  string2(string2 &) { i = other.i; }
+  int i;
+} string2 get_string2() {
+  string2 result;
+  result.i = 5;
+  some_function(result.i);
+  // Test that the debugger can get the value of result after another
+  // function is called.
+  // DEBUGGER: break 35
+  return result;
+}
+int main() {
+  get_string();
+  get_string2();
+}
 
 // DEBUGGER: r
 // DEBUGGER: print result.i
 // CHECK:  = 3
+// DEBUGGER: c
+// DEBUGGER: print result.i
+// CHECK:  = 5
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -327,6 +327,10 @@
   /// value. This is invalid iff the function has no return value.
   Address ReturnValue = Address::invalid();
 
+  /// ReturnValuePointer - The temporary alloca to hold a pointer to sret.
+  /// This is invalid if sret is not in use.
+  Address ReturnValuePointer = Address::invalid();
+
   /// Return true if a label was seen in the current scope.
   bool hasLabelBeenSeenInCurrentScope() const {
 if (CurLexicalScope)
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -895,6 +895,10 @@
 if (CurFnInfo->getReturnInfo().isSRetAfterThis())
   ++AI;
 ReturnValue = Address(&*AI, CurFnInfo->getReturnInfo().getIndirectAlign());
+ReturnValuePointer = CreateDefaultAlignTempAlloca(Int8PtrTy, "result.ptr");
+Builder.CreateStore(Builder.CreatePointerBitCastOrAddrSpaceCast(
+ReturnValue.getPointer(), Int8PtrTy),
+ReturnValuePointer);
   } else if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::InAlloca &&
  !hasScalarEvaluationKind(CurFnInfo->getReturnType())) {
 // Load the sret pointer from the argument struct and return into that.
@@ -904,6 +908,10 @@
 llvm::Value *Addr = Builder.CreateStructGEP(nullptr, &*EI, Idx);
 Addr = Builder.CreateAlignedLoad(Addr, getPointerAlign(), "agg.result");
 ReturnValue = Address(Addr, getNaturalTypeAlignment(RetTy));
+ReturnValuePointer = CreateDefaultAlignTempAlloca(Int8PtrTy, "result.ptr");
+Builder.CreateStore(Builder.CreatePointerBitCastOrAddrSpaceCast(
+ReturnValue.getPointer(), Int8PtrTy),
+ReturnValuePointer);
   } else {
 ReturnValue = 

[PATCH] D63498: [RISC-V] Add -msave-restore and -mno-save-restore to clang driver

2019-06-18 Thread Sam Elliott via Phabricator via cfe-commits
lenary created this revision.
lenary added reviewers: asb, luismarques.
Herald added subscribers: cfe-commits, jocewei, PkmX, rkruppe, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar.
Herald added a project: clang.

The GCC RISC-V toolchain accepts `-msave-restore` and `-mno-save-restore`
to control whether libcalls are used for saving and restoring the stack within
prologues and epilogues.

Clang currently errors if someone passes -msave-restore or -mno-save-restore.
This means that people need to change build configurations to use clang. This
patch adds these flags, so that clang invocations can now match gcc.

As the RISC-V backend does not currently have a `save-restore` target feature,
we emit a warning if someone requests `-msave-restore`. LLVM does not error if
we pass the (unimplemented) target features `+save-restore` or `-save-restore`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63498

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-features.c


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -3,11 +3,20 @@
 
 // CHECK: fno-signed-char
 
+// RUN: %clang -target riscv32-unknown-elf -### %s 2>&1 | FileCheck %s 
-check-prefix=DEFAULT
+
 // RUN: %clang -target riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s 
-check-prefix=RELAX
 // RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck 
%s -check-prefix=NO-RELAX
-// RUN: %clang -target riscv32-unknown-elf -### %s 2>&1 | FileCheck %s 
-check-prefix=DEFAULT
 
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
 // DEFAULT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"
+
+// RUN: %clang -target riscv32-unknown-elf -### %s -msave-restore 2>&1 | 
FileCheck %s -check-prefix=SAVE-RESTORE
+// RUN: %clang -target riscv32-unknown-elf -### %s -mno-save-restore 2>&1 | 
FileCheck %s -check-prefix=NO-SAVE-RESTORE
+
+// SAVE-RESTORE: "-target-feature" "+save-restore"
+// NO-SAVE-RESTORE: "-target-feature" "-save-restore"
+// DEFAULT: "-target-feature" "-save-restore"
+// DEFAULT-NOT: "-target-feature" "+save-restore"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -358,6 +358,16 @@
   else
 Features.push_back("-relax");
 
+  // -mno-save-restore is default, unless -msave-restore is specified.
+  if (Args.hasFlag(options::OPT_msave_restore, options::OPT_mno_save_restore, 
false)) {
+Features.push_back("+save-restore");
+// ... but we don't yet support +save-restore, so issue a warning.
+D.Diag(diag::warn_drv_clang_unsupported)
+  << Args.getLastArg(options::OPT_msave_restore)->getAsString(Args);
+  } else {
+Features.push_back("-save-restore");
+  }
+
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(Args, Features, 
options::OPT_m_riscv_Features_Group);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2125,6 +2125,10 @@
   HelpText<"Enable linker relaxation">;
 def mno_relax : Flag<["-"], "mno-relax">, Group,
   HelpText<"Disable linker relaxation">;
+def msave_restore : Flag<["-"], "msave-restore">, 
Group,
+  HelpText<"Enable using library calls for save and restore">;
+def mno_save_restore : Flag<["-"], "mno-save-restore">, 
Group,
+  HelpText<"Disable using library calls for save and restore">;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, 
Group,
   HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -3,11 +3,20 @@
 
 // CHECK: fno-signed-char
 
+// RUN: %clang -target riscv32-unknown-elf -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+
 // RUN: %clang -target riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s -check-prefix=RELAX
 // RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck %s -check-prefix=NO-RELAX
-// RUN: %clang -target riscv32-unknown-elf -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
 
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
 // DEFAULT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"
+
+// RUN: %clang -target riscv32-unknown-elf -### %s -msave-restore 2>&1 | FileCheck %s 

[PATCH] D62953: [Syntax] Do not glue multiple empty PP expansions to a single mapping

2019-06-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D62953#1547799 , @sammccall wrote:

> Can you explain why this is important?
>  (in the code)


I've added a few comments into the code that builds token buffers, but I 
couldn't figure out a good place to mention this in the API docs.
It would be a natural expectation from the API from my POV, the fact that we 
glued empty expansions together is an implementation artifact rather than a 
sensible contract...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62953



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


[PATCH] D62953: [Syntax] Do not glue multiple empty PP expansions to a single mapping

2019-06-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 205377.
ilya-biryukov added a comment.

- Added comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62953

Files:
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -428,7 +428,9 @@
   spelled tokens:
 # define EMPTY # define EMPTY_FUNC ( X ) EMPTY EMPTY_FUNC ( 1 + 2 + 3 )
   mappings:
-['#'_0, ''_18) => [''_0, ''_0)
+['#'_0, 'EMPTY'_9) => [''_0, ''_0)
+['EMPTY'_9, 'EMPTY_FUNC'_10) => [''_0, ''_0)
+['EMPTY_FUNC'_10, ''_18) => [''_0, ''_0)
 )"},
   // File ends with a macro replacement.
   {R"cpp(
Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -252,6 +253,33 @@
   return Tokens;
 }
 
+class TokenCollector::Callbacks : public PPCallbacks {
+public:
+  Callbacks(TokenCollector ) : C() {}
+
+  /// Disabled instance will stop reporting anything to TokenCollector.
+  void disable() { C = nullptr; }
+
+  void MacroExpands(const clang::Token , const MacroDefinition ,
+SourceRange Range, const MacroArgs *Args) override {
+if (!C)
+  return;
+// Do not record recursive expansions.
+if (!MacroNameTok.getLocation().isFileID() ||
+(LastExpansionEnd.isValid() &&
+ C->PP.getSourceManager().isBeforeInTranslationUnit(Range.getBegin(),
+LastExpansionEnd)))
+  return;
+C->Mappings[Range.getBegin().getRawEncoding()] = Range.getEnd();
+LastExpansionEnd = Range.getEnd();
+  }
+  // FIXME: handle #pragma, #include, etc.
+private:
+  TokenCollector *C;
+  /// Used to detect recursive macro expansions.
+  SourceLocation LastExpansionEnd;
+};
+
 /// Fills in the TokenBuffer by tracing the run of a preprocessor. The
 /// implementation tracks the tokens, macro expansions and directives coming
 /// from the preprocessor and:
@@ -279,15 +307,20 @@
 );
 Expanded.push_back(syntax::Token(T));
   });
+  // And locations of macro calls, to properly recover boundaries of those in
+  // case of empty expansions.
+  auto CB = llvm::make_unique(*this);
+  this->CB = CB.get();
+  PP.addPPCallbacks(std::move(CB));
 }
 
 /// Builds mappings and spelled tokens in the TokenBuffer based on the expanded
 /// token stream.
 class TokenCollector::Builder {
 public:
-  Builder(std::vector Expanded, const SourceManager ,
-  const LangOptions )
-  : Result(SM), SM(SM), LangOpts(LangOpts) {
+  Builder(std::vector Expanded, SpelledMappings Mappings,
+  const SourceManager , const LangOptions )
+  : Result(SM), Mappings(std::move(Mappings)), SM(SM), LangOpts(LangOpts) {
 Result.ExpandedTokens = std::move(Expanded);
   }
 
@@ -296,6 +329,9 @@
 
 // Walk over expanded tokens and spelled tokens in parallel, building the
 // mappings between those using source locations.
+// To correctly recover empty macro expansions, we also take locations
+// reported to PPCallbacks::MacroExpands into account as we do not have any
+// expanded tokens with source locations to guide us.
 
 // The 'eof' token is special, it is not part of spelled token stream. We
 // handle it separately at the end.
@@ -356,22 +392,17 @@
 
 fillGapUntil(File, SpelledRange.getBegin(), I);
 
-TokenBuffer::Mapping M;
-// Skip the spelled macro tokens.
-std::tie(M.BeginSpelled, M.EndSpelled) =
-consumeSpelledUntil(File, SpelledRange.getEnd().getLocWithOffset(1));
 // Skip all expanded tokens from the same macro expansion.
-M.BeginExpanded = I;
+unsigned BeginExpanded = I;
 for (; I + 1 < Result.ExpandedTokens.size(); ++I) {
   auto NextL = Result.ExpandedTokens[I + 1].location();
   if (!NextL.isMacroID() ||
   SM.getExpansionLoc(NextL) != SpelledRange.getBegin())
 break;
 }
-M.EndExpanded = I + 1;
-
-// Add a resulting mapping.
-File.Mappings.push_back(M);
+unsigned EndExpanded = I + 1;
+consumeMapping(File, SM.getFileOffset(SpelledRange.getEnd()), BeginExpanded,
+   EndExpanded, NextSpelled[FID]);
   }
 
   /// Initializes TokenBuffer::Files and fills spelled tokens and expanded
@@ -393,69 +424,108 @@
 }
   }
 
-  /// Consumed spelled 

  1   2   3   >