[PATCH] D60543: [clang] Update isDerivedFrom to support Objective-C classes 

2019-05-28 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore planned changes to this revision.
stephanemoore added a comment.

Thanks for the input! I will get started on making changes accordingly.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2642-2649
+  if (const auto *InterfaceDecl = dyn_cast()) {
+// Check if any of the superclasses of the class match.
+for (const ObjCInterfaceDecl *SuperClass = InterfaceDecl->getSuperClass();
+ SuperClass != nullptr; SuperClass = SuperClass->getSuperClass()) {
+  if (Base.matches(*SuperClass, Finder, Builder))
+return true;
+}

aaron.ballman wrote:
> This should probably be done similar to how `classIsDerivedFrom()` works. For 
> instance, there's some type alias matching logic that this does not 
> replicate, but we probably want.
Upon first glance I had determined that the type aliasing logic in 
`classIsDerivedFrom()` was particular to C++. On second consideration, we will 
probably want to make sure that compatibility aliases are handled correctly for 
Objective-C. I will take a look into making sure that works as expected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60543



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


r361920 - Make __has_builtin work with __builtin_LINE and friends.

2019-05-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May 28 20:15:36 2019
New Revision: 361920

URL: http://llvm.org/viewvc/llvm-project?rev=361920=rev
Log:
Make __has_builtin work with __builtin_LINE and friends.

The source location builtins are implemented as keywords, but
__has_builtin should still report true for them.

This patch also fixes a test failure on systemz where the alignment
of string literals is 2 not 1.

Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp
cfe/trunk/test/Preprocessor/feature_tests.c

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=361920=361919=361920=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue May 28 20:15:36 2019
@@ -1620,6 +1620,10 @@ void Preprocessor::ExpandBuiltinMacro(To
   .Case("__is_target_vendor", true)
   .Case("__is_target_os", true)
   .Case("__is_target_environment", true)
+  .Case("__builtin_LINE", true)
+  .Case("__builtin_FILE", true)
+  .Case("__builtin_FUNCTION", true)
+  .Case("__builtin_COLUMN", true)
   .Default(false);
 }
   });

Modified: cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp?rev=361920=361919=361920=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin_FUNCTION.cpp Tue May 28 20:15:36 2019
@@ -6,7 +6,7 @@ namespace test_func {
 constexpr const char *test_default_arg(const char *f = __builtin_FUNCTION()) {
   return f;
 }
-// CHECK: @[[EMPTY_STR:.+]] = private unnamed_addr constant [1 x i8] 
zeroinitializer, align 1
+// CHECK: @[[EMPTY_STR:.+]] = private unnamed_addr constant [1 x i8] 
zeroinitializer
 
 // CHECK: @_ZN9test_func6globalE = {{(dso_local )?}}global i8* getelementptr 
inbounds ([1 x i8], [1 x i8]* @[[EMPTY_STR]], i32 0, i32 0)
 const char *global = test_default_arg();
@@ -16,9 +16,9 @@ const char *global_two = __builtin_FUNCT
 
 const char * const global_three = test_default_arg();
 
-// CHECK: @[[STR_ONE:.+]] = private unnamed_addr constant [14 x i8] 
c"test_func_one\00", align 1
-// CHECK: @[[STR_TWO:.+]] = private unnamed_addr constant [14 x i8] 
c"test_func_two\00", align 1
-// CHECK: @[[STR_THREE:.+]] = private unnamed_addr constant [20 x i8] 
c"do_default_arg_test\00", align 1
+// CHECK: @[[STR_ONE:.+]] = private unnamed_addr constant [14 x i8] 
c"test_func_one\00"
+// CHECK: @[[STR_TWO:.+]] = private unnamed_addr constant [14 x i8] 
c"test_func_two\00"
+// CHECK: @[[STR_THREE:.+]] = private unnamed_addr constant [20 x i8] 
c"do_default_arg_test\00"
 
 // CHECK: define {{(dso_local )?}}i8* @_ZN9test_func13test_func_oneEv()
 // CHECK: ret i8* getelementptr inbounds ([14 x i8], [14 x i8]* @[[STR_ONE]], 
i32 0, i32 0)

Modified: cfe/trunk/test/Preprocessor/feature_tests.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/feature_tests.c?rev=361920=361919=361920=diff
==
--- cfe/trunk/test/Preprocessor/feature_tests.c (original)
+++ cfe/trunk/test/Preprocessor/feature_tests.c Tue May 28 20:15:36 2019
@@ -20,6 +20,15 @@
 #error Clang should have these
 #endif
 
+// These are technically implemented as keywords, but __has_builtin should
+// still return true.
+#if !__has_builtin(__builtin_LINE) || \
+!__has_builtin(__builtin_FILE) || \
+!__has_builtin(__builtin_FUNCTION) || \
+!__has_builtin(__builtin_COLUMN)
+#error Clang should have these
+#endif
+
 #if __has_builtin(__builtin_insanity)
 #error Clang should not have this
 #endif


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


[PATCH] D62121: [PowerPC] [Clang] Port SSE intrinsics to PowerPC

2019-05-28 Thread Zixuan Wu via Phabricator via cfe-commits
wuzish added a comment.

Thanks. I will commit for @qiucf


Repository:
  rC Clang

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

https://reviews.llvm.org/D62121



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


[PATCH] D62121: [PowerPC] [Clang] Port SSE intrinsics to PowerPC

2019-05-28 Thread Jinsong Ji via Phabricator via cfe-commits
jsji accepted this revision.
jsji added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for porting.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62121



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


[PATCH] D62045: Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-28 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore reopened this revision.
stephanemoore added inline comments.
This revision is now accepted and ready to land.



Comment at: test/clang-tidy/google-objc-global-variable-declaration.m:48
 static NSString* gMyIntGood = 0;
+extern NSString* Y2Good;
 

Whoops, we forgot the warning that should be generated for this case 

Test failure(s):
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/49124
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/49124/steps/test/logs/stdio

I had to rollback the commit. Can you update the patch to resolve the test 
failure(s)?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62045



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


[PATCH] D62483: [CUDA][HIP] Emit dependent libs for host only

2019-05-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This seems to be failing on macOS bots with the following error:

  FAIL: Clang :: CodeGenCUDA/dependent-libs.cu (3052 of 14933)
   TEST 'Clang :: CodeGenCUDA/dependent-libs.cu' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/lib/clang/9.0.0/include 
-nostdsysteminc -emit-llvm -o - -fcuda-is-device -x hip 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu | 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/FileCheck 
--check-prefix=DEV 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu
  : 'RUN: at line 2';   
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/lib/clang/9.0.0/include 
-nostdsysteminc -emit-llvm -o - -x hip 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu | 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/FileCheck 
--check-prefix=HOST 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  /b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu:5:10: 
error: HOST: expected string not found in input
  // HOST: llvm.dependent-libraries
   ^
  :1:1: note: scanning from here
  ; ModuleID = 
'/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu'
  ^
  :1:58: note: possible intended match here
  ; ModuleID = 
'/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu'
   ^
  
  --

The full test log is here: 
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8912171419117598448/+/steps/clang/0/steps/test/0/stdout


Repository:
  rC Clang

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

https://reviews.llvm.org/D62483



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


[PATCH] D62509: [Driver] Render -fuse-init-array for -fembed-bitcode

2019-05-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:3675
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+

compnerd wrote:
> Hmm, what other arguments will this render into the option handling that we 
> weren't handling before?
`-fuse-init-array` is the only one on Linux x86. Other OSes/targets may have 
more, e.g. Hexagon has:

void HexagonToolChain::addClangTargetOptions(const ArgList ,
 ArgStringList ,
 Action::OffloadKind) const {
  if (DriverArgs.hasArg(options::OPT_ffixed_r19)) {
CC1Args.push_back("-target-feature");
CC1Args.push_back("+reserved-r19");
  }
  if (isAutoHVXEnabled(DriverArgs)) {
CC1Args.push_back("-mllvm");
CC1Args.push_back("-hexagon-autohvx");
  }
}

NetBSD has a -D (it should not matter):

void NetBSD::addClangTargetOptions(const ArgList &,
   ArgStringList ,
   Action::OffloadKind) const {
  const SanitizerArgs  = getSanitizerArgs();
  if (SanArgs.hasAnySanitizer())
CC1Args.push_back("-D_REENTRANT");
}



Repository:
  rC Clang

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

https://reviews.llvm.org/D62509



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


[PATCH] D62551: [analyzer][Dominator] Add post dominator tree builder for the CFG + a debug checker

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

Dunno, looks great :)

Also thx @kuhar!




Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:194-195
 using ClangCFGDomChildrenGetter =
-SemiNCAInfo>::ChildrenGetter;
+SemiNCAInfo::ChildrenGetter<
+ 
/*Inverse=*/false>;
 

Is this the intended formatting?


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

https://reviews.llvm.org/D62551



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


[PATCH] D62045: Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-28 Thread Stephane Moore via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE361907: Revise the google-objc-global-variable-declaration 
check to match the style… (authored by stephanemoore, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62045?vs=201352=201806#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62045

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m

Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -23,29 +23,35 @@
 
 namespace {
 
-AST_MATCHER(VarDecl, isLocalVariable) {
-  return Node.isLocalVarDecl();
-}
+AST_MATCHER(VarDecl, isLocalVariable) { return Node.isLocalVarDecl(); }
 
 FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
+  if (IsConst && (Decl->getStorageClass() != SC_Static)) {
+// No fix available if it is not a static constant, since it is difficult
+// to determine the proper fix in this case.
+return FixItHint();
+  }
+
   char FC = Decl->getName()[0];
   if (!llvm::isAlpha(FC) || Decl->getName().size() == 1) {
 // No fix available if first character is not alphabetical character, or it
-// is a single-character variable, since it is difficult to determine the 
+// is a single-character variable, since it is difficult to determine the
 // proper fix in this case. Users should create a proper variable name by
 // their own.
 return FixItHint();
   }
   char SC = Decl->getName()[1];
   if ((FC == 'k' || FC == 'g') && !llvm::isAlpha(SC)) {
-// No fix available if the prefix is correct but the second character is not
-// alphabetical, since it is difficult to determine the proper fix in this
-// case.
+// No fix available if the prefix is correct but the second character is
+// not alphabetical, since it is difficult to determine the proper fix in
+// this case.
 return FixItHint();
   }
+
   auto NewName = (IsConst ? "k" : "g") +
  llvm::StringRef(std::string(1, FC)).upper() +
  Decl->getName().substr(1).str();
+
   return FixItHint::CreateReplacement(
   CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
   llvm::StringRef(NewName));
@@ -71,7 +77,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
+ unless(matchesName("::(k[A-Z])|([A-Z][A-Z0-9])")))
  .bind("global_const"),
  this);
 }
Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -1,10 +1,14 @@
 // RUN: %check_clang_tidy %s google-objc-global-variable-declaration %t
 
 @class NSString;
+
 static NSString* const myConstString = @"hello";
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
+extern NSString* const GlobalConstant = @"hey";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'GlobalConstant' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
+
 static NSString* MyString = @"hi";
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: non-const global variable 'MyString' must have a name which starts with 'g[A-Z]' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* gMyString = @"hi";
@@ -25,13 +29,23 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
+static NSString* const notCap = @"NotBeginWithCap";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'notCap' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
+// CHECK-FIXES: static NSString* const kNotCap = @"NotBeginWithCap";
+
 static NSString* const k_Alpha = @"SecondNotAlpha";
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
+static NSString* const 

[clang-tools-extra] r361907 - Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-28 Thread Stephane Moore via cfe-commits
Author: stephanemoore
Date: Tue May 28 18:36:23 2019
New Revision: 361907

URL: http://llvm.org/viewvc/llvm-project?rev=361907=rev
Log:
Revise the google-objc-global-variable-declaration check to match the style 
guide.

Summary:
Revise the google-objc-global-variable-declaration check to match the style 
guide.

This commit updates the check as follows:
(1) Do not emit fixes for extern global constants.
(2) Allow the second character of prefixes for constants to be numeric (the new 
guideline is that global constants should generally be named with a prefix that 
begins with a capital letter followed by one or more capital letters or 
numbers).

https://google.github.io/styleguide/objcguide.html#prefixes

Contributed by yaqiji.

Reviewers: Wizard, benhamilton, stephanemoore

Reviewed By: benhamilton, stephanemoore

Subscribers: mgorny, cfe-commits, yaqiji

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/google-objc-global-variable-declaration.m

Modified: 
clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.cpp?rev=361907=361906=361907=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/google/GlobalVariableDeclarationCheck.cpp 
Tue May 28 18:36:23 2019
@@ -23,29 +23,35 @@ namespace objc {
 
 namespace {
 
-AST_MATCHER(VarDecl, isLocalVariable) {
-  return Node.isLocalVarDecl();
-}
+AST_MATCHER(VarDecl, isLocalVariable) { return Node.isLocalVarDecl(); }
 
 FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
+  if (IsConst && (Decl->getStorageClass() != SC_Static)) {
+// No fix available if it is not a static constant, since it is difficult
+// to determine the proper fix in this case.
+return FixItHint();
+  }
+
   char FC = Decl->getName()[0];
   if (!llvm::isAlpha(FC) || Decl->getName().size() == 1) {
 // No fix available if first character is not alphabetical character, or it
-// is a single-character variable, since it is difficult to determine the 
+// is a single-character variable, since it is difficult to determine the
 // proper fix in this case. Users should create a proper variable name by
 // their own.
 return FixItHint();
   }
   char SC = Decl->getName()[1];
   if ((FC == 'k' || FC == 'g') && !llvm::isAlpha(SC)) {
-// No fix available if the prefix is correct but the second character is 
not
-// alphabetical, since it is difficult to determine the proper fix in this
-// case.
+// No fix available if the prefix is correct but the second character is
+// not alphabetical, since it is difficult to determine the proper fix in
+// this case.
 return FixItHint();
   }
+
   auto NewName = (IsConst ? "k" : "g") +
  llvm::StringRef(std::string(1, FC)).upper() +
  Decl->getName().substr(1).str();
+
   return FixItHint::CreateReplacement(
   CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
   llvm::StringRef(NewName));
@@ -71,7 +77,7 @@ void GlobalVariableDeclarationCheck::reg
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
+ unless(matchesName("::(k[A-Z])|([A-Z][A-Z0-9])")))
  .bind("global_const"),
  this);
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/google-objc-global-variable-declaration.m
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-objc-global-variable-declaration.m?rev=361907=361906=361907=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/google-objc-global-variable-declaration.m
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/google-objc-global-variable-declaration.m
 Tue May 28 18:36:23 2019
@@ -1,10 +1,14 @@
 // RUN: %check_clang_tidy %s google-objc-global-variable-declaration %t
 
 @class NSString;
+
 static NSString* const myConstString = @"hello";
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have a name which starts with an appropriate prefix 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
+extern NSString* const GlobalConstant = @"hey";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'GlobalConstant' must have a name which starts with an appropriate prefix 

r361905 - Fix failure of lit test dependent-libs.cu

2019-05-28 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue May 28 18:34:44 2019
New Revision: 361905

URL: http://llvm.org/viewvc/llvm-project?rev=361905=rev
Log:
Fix failure of lit test dependent-libs.cu

Modified:
cfe/trunk/test/CodeGenCUDA/dependent-libs.cu

Modified: cfe/trunk/test/CodeGenCUDA/dependent-libs.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/dependent-libs.cu?rev=361905=361904=361905=diff
==
--- cfe/trunk/test/CodeGenCUDA/dependent-libs.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/dependent-libs.cu Tue May 28 18:34:44 2019
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck 
--check-prefix=DEV %s
-// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -o - -fcuda-is-device 
-x hip %s | FileCheck --check-prefix=DEV %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -x hip %s | 
FileCheck --check-prefix=HOST %s
 
 // DEV-NOT: llvm.dependent-libraries
 // HOST: llvm.dependent-libraries


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


[PATCH] D62367: [X86] VP2INTERSECT clang

2019-05-28 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm updated this revision to Diff 201805.
xiangzhangllvm added a comment.

rebase


Repository:
  rC Clang

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

https://reviews.llvm.org/D62367

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/avx512vlvp2intersectintrin.h
  lib/Headers/avx512vp2intersectintrin.h
  lib/Headers/immintrin.h
  test/CodeGen/attr-target-x86.c
  test/CodeGen/intel-avx512vlvp2intersect.c
  test/CodeGen/intel-avx512vp2intersect.c
  test/Driver/x86-target-features.c
  test/Preprocessor/x86_target_features.c

Index: test/Preprocessor/x86_target_features.c
===
--- test/Preprocessor/x86_target_features.c
+++ test/Preprocessor/x86_target_features.c
@@ -458,3 +458,13 @@
 
 // AVX512BF16_NOAVX512VL: #define __AVX512BF16__ 1
 
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mavx512vp2intersect -x c -E -dM -o - %s | FileCheck  -check-prefix=VP2INTERSECT %s
+
+// VP2INTERSECT: #define __AVX512F__ 1
+// VP2INTERSECT: #define __AVX512VP2INTERSECT__ 1
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-avx512vp2intersect -x c -E -dM -o - %s | FileCheck  -check-prefix=NOVP2INTERSECT %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mavx512vp2intersect -mno-avx512f -x c -E -dM -o - %s | FileCheck  -check-prefix=NOVP2INTERSECT %s
+
+// NOVP2INTERSECT-NOT: #define __AVX512VP2INTERSECT__ 1
+
Index: test/Driver/x86-target-features.c
===
--- test/Driver/x86-target-features.c
+++ test/Driver/x86-target-features.c
@@ -125,6 +125,11 @@
 // VBMI2: "-target-feature" "+avx512vbmi2"
 // NO-VBMI2: "-target-feature" "-avx512vbmi2"
 
+// RUN: %clang -target i386-linux-gnu -mavx512vp2intersect %s -### -o %t.o 2>&1 | FileCheck -check-prefix=VP2INTERSECT %s
+// RUN: %clang -target i386-linux-gnu -mno-avx512vp2intersect %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-VP2INTERSECT %s
+// VP2INTERSECT: "-target-feature" "+avx512vp2intersect"
+// NO-VP2INTERSECT: "-target-feature" "-avx512vp2intersect"
+
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mrdpid %s -### -o %t.o 2>&1 | FileCheck -check-prefix=RDPID %s
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-rdpid %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-RDPID %s
 // RDPID: "-target-feature" "+rdpid"
Index: test/CodeGen/intel-avx512vp2intersect.c
===
--- /dev/null
+++ test/CodeGen/intel-avx512vp2intersect.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +avx512vp2intersect -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -ffreestanding -triple=i386-unknown-unknown -target-feature +avx512vp2intersect -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_mm512_2intersect_epi32(__m512i a, __m512i b, __mmask16 *m0, __mmask16 *m1) {
+// CHECK-LABEL: test_mm512_2intersect_epi32
+// CHECK: call { <16 x i1>, <16 x i1> } @llvm.x86.avx512.vp2intersect.d.512(<16 x i32> %{{.*}}, <16 x i32> %{{.*}})
+// CHECK: extractvalue { <16 x i1>, <16 x i1> } %{{.*}}, 0
+// CHECK: extractvalue { <16 x i1>, <16 x i1> } %{{.*}}, 1
+  _mm512_2intersect_epi32(a, b, m0, m1);
+}
+
+void test_mm512_2intersect_epi64(__m512i a, __m512i b, __mmask8 *m0, __mmask8 *m1) {
+// CHECK-LABEL: test_mm512_2intersect_epi64
+// CHECK: call { <8 x i1>, <8 x i1> } @llvm.x86.avx512.vp2intersect.q.512(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
+// CHECK: extractvalue { <8 x i1>, <8 x i1> } %{{.*}}, 0
+// CHECK: extractvalue { <8 x i1>, <8 x i1> } %{{.*}}, 1
+  _mm512_2intersect_epi64(a, b, m0, m1);
+}
Index: test/CodeGen/intel-avx512vlvp2intersect.c
===
--- /dev/null
+++ test/CodeGen/intel-avx512vlvp2intersect.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +avx512vp2intersect -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -ffreestanding -triple=i386-unknown-unknown -target-feature +avx512vp2intersect -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_mm256_2intersect_epi32(__m256i a, __m256i b, __mmask8 *m0, __mmask8 *m1) {
+// CHECK-LABEL: test_mm256_2intersect_epi32
+// CHECK: call { <8 x i1>, <8 x i1> } @llvm.x86.avx512.vp2intersect.d.256(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
+// CHECK: extractvalue { <8 x i1>, <8 x i1> } %{{.*}}, 0
+// CHECK: extractvalue { <8 x i1>, <8 x i1> } %{{.*}}, 1
+  _mm256_2intersect_epi32(a, b, m0, m1);
+}
+
+void test_mm256_2intersect_epi64(__m256i a, __m256i b, __mmask8 *m0, __mmask8 *m1) {
+// CHECK-LABEL: 

[PATCH] D62559: [WebAssembly] Support VPtr sanitizer for Emscripten

2019-05-28 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:214
+  if (getTriple().isOSEmscripten()) {
+Res |= SanitizerKind::Vptr;
+  }

aheejin wrote:
> quantum wrote:
> > aheejin wrote:
> > > quantum wrote:
> > > > aheejin wrote:
> > > > > Does this mean we only support `Vptr` among sanitizers [[ 
> > > > > https://github.com/llvm/llvm-project/blob/92d706eaca6cc79501066eae4392b68e52c1/clang/include/clang/Basic/Sanitizers.def#L76-L103
> > > > >  | here ]]?
> > > > No, by default all of UBSan except `Vptr` and `Function` are declared 
> > > > as supported. This adds Vptr to the list as it's supported on 
> > > > Emscripten.
> > > I see. By the way where do we say we support the undefined sanitizer 
> > > group?
> > The base `ToolChain` class says it's supported on all platforms.
> By the way [[ 
> https://github.com/llvm/llvm-project/blob/92d706eaca6cc79501066eae4392b68e52c1/clang/include/clang/Basic/Sanitizers.def#L129-L137
>  | this ]] seems to include `Vptr` as well..? Am I looking at the wrong place?
Oh nevermind, the base method explicitly excludes `Vptr` and `Function`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62559



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


[PATCH] D62559: [WebAssembly] Support VPtr sanitizer for Emscripten

2019-05-28 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:214
+  if (getTriple().isOSEmscripten()) {
+Res |= SanitizerKind::Vptr;
+  }

quantum wrote:
> aheejin wrote:
> > quantum wrote:
> > > aheejin wrote:
> > > > Does this mean we only support `Vptr` among sanitizers [[ 
> > > > https://github.com/llvm/llvm-project/blob/92d706eaca6cc79501066eae4392b68e52c1/clang/include/clang/Basic/Sanitizers.def#L76-L103
> > > >  | here ]]?
> > > No, by default all of UBSan except `Vptr` and `Function` are declared as 
> > > supported. This adds Vptr to the list as it's supported on Emscripten.
> > I see. By the way where do we say we support the undefined sanitizer group?
> The base `ToolChain` class says it's supported on all platforms.
By the way [[ 
https://github.com/llvm/llvm-project/blob/92d706eaca6cc79501066eae4392b68e52c1/clang/include/clang/Basic/Sanitizers.def#L129-L137
 | this ]] seems to include `Vptr` as well..? Am I looking at the wrong place?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62559



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


[PATCH] D62559: [WebAssembly] Support VPtr sanitizer for Emscripten

2019-05-28 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum marked 2 inline comments as done.
quantum added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:214
+  if (getTriple().isOSEmscripten()) {
+Res |= SanitizerKind::Vptr;
+  }

aheejin wrote:
> quantum wrote:
> > aheejin wrote:
> > > Does this mean we only support `Vptr` among sanitizers [[ 
> > > https://github.com/llvm/llvm-project/blob/92d706eaca6cc79501066eae4392b68e52c1/clang/include/clang/Basic/Sanitizers.def#L76-L103
> > >  | here ]]?
> > No, by default all of UBSan except `Vptr` and `Function` are declared as 
> > supported. This adds Vptr to the list as it's supported on Emscripten.
> I see. By the way where do we say we support the undefined sanitizer group?
The base `ToolChain` class says it's supported on all platforms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62559



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


[PATCH] D62559: [WebAssembly] Support VPtr sanitizer for Emscripten

2019-05-28 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 201803.
quantum marked an inline comment as done.
quantum added a comment.

Add a test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62559

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/test/CodeGenCXX/wasm-sanitize-vptr.cpp


Index: clang/test/CodeGenCXX/wasm-sanitize-vptr.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/wasm-sanitize-vptr.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -fsanitize=vptr -emit-llvm %s -o - -triple 
wasm32-unknown-emscripten | FileCheck %s
+
+struct S {
+  virtual ~S() {}
+  int a;
+};
+
+struct T : S {
+  int b;
+};
+
+// CHECK-LABEL: @_Z15bad_static_castv
+void bad_static_cast() {
+  S s;
+  // CHECK: br i1 %[[NONNULL:.*]], label %[[CONT:.*]], label %[[MISS:.*]], 
!prof
+  // CHECK: [[MISS]]:
+  // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss_abort
+  // CHECK: [[CONT]]:
+  T  = static_cast(s);
+}
Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -66,6 +66,7 @@
   llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
+  SanitizerMask getSupportedSanitizers() const override;
 
   const char *getDefaultLinker() const override { return "wasm-ld"; }
 
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -208,6 +208,14 @@
   }
 }
 
+SanitizerMask WebAssembly::getSupportedSanitizers() const {
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+  if (getTriple().isOSEmscripten()) {
+Res |= SanitizerKind::Vptr;
+  }
+  return Res;
+}
+
 Tool *WebAssembly::buildLinker() const {
   return new tools::wasm::Linker(*this);
 }


Index: clang/test/CodeGenCXX/wasm-sanitize-vptr.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/wasm-sanitize-vptr.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -fsanitize=vptr -emit-llvm %s -o - -triple wasm32-unknown-emscripten | FileCheck %s
+
+struct S {
+  virtual ~S() {}
+  int a;
+};
+
+struct T : S {
+  int b;
+};
+
+// CHECK-LABEL: @_Z15bad_static_castv
+void bad_static_cast() {
+  S s;
+  // CHECK: br i1 %[[NONNULL:.*]], label %[[CONT:.*]], label %[[MISS:.*]], !prof
+  // CHECK: [[MISS]]:
+  // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss_abort
+  // CHECK: [[CONT]]:
+  T  = static_cast(s);
+}
Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -66,6 +66,7 @@
   llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
+  SanitizerMask getSupportedSanitizers() const override;
 
   const char *getDefaultLinker() const override { return "wasm-ld"; }
 
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -208,6 +208,14 @@
   }
 }
 
+SanitizerMask WebAssembly::getSupportedSanitizers() const {
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+  if (getTriple().isOSEmscripten()) {
+Res |= SanitizerKind::Vptr;
+  }
+  return Res;
+}
+
 Tool *WebAssembly::buildLinker() const {
   return new tools::wasm::Linker(*this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62559: [WebAssembly] Support VPtr sanitizer for Emscripten

2019-05-28 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:214
+  if (getTriple().isOSEmscripten()) {
+Res |= SanitizerKind::Vptr;
+  }

quantum wrote:
> aheejin wrote:
> > Does this mean we only support `Vptr` among sanitizers [[ 
> > https://github.com/llvm/llvm-project/blob/92d706eaca6cc79501066eae4392b68e52c1/clang/include/clang/Basic/Sanitizers.def#L76-L103
> >  | here ]]?
> No, by default all of UBSan except `Vptr` and `Function` are declared as 
> supported. This adds Vptr to the list as it's supported on Emscripten.
I see. By the way where do we say we support the undefined sanitizer group?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62559



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


[PATCH] D62559: [WebAssembly] Support VPtr sanitizer for Emscripten

2019-05-28 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum marked 2 inline comments as done.
quantum added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:214
+  if (getTriple().isOSEmscripten()) {
+Res |= SanitizerKind::Vptr;
+  }

aheejin wrote:
> Does this mean we only support `Vptr` among sanitizers [[ 
> https://github.com/llvm/llvm-project/blob/92d706eaca6cc79501066eae4392b68e52c1/clang/include/clang/Basic/Sanitizers.def#L76-L103
>  | here ]]?
No, by default all of UBSan except `Vptr` and `Function` are declared as 
supported. This adds Vptr to the list as it's supported on Emscripten.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62559



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


[PATCH] D62559: [WebAssembly] Support VPtr sanitizer for Emscripten

2019-05-28 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

Please add a test!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62559



___
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-05-28 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran updated this revision to Diff 201799.
DiegoAstiazaran added a comment.

Fix patch submitted.
Patch submitted with the last update was a new commit, functional changes were 
not included in that diff.
New patch includes functional changes (first patch) and format changes (second 
patch / first update).


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

https://reviews.llvm.org/D62437

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

Index: clang-tools-extra/test/clang-tidy/fuchsia-default-arguments-declarations.cpp
===
--- clang-tools-extra/test/clang-tidy/fuchsia-default-arguments-declarations.cpp
+++ clang-tools-extra/test/clang-tidy/fuchsia-default-arguments-declarations.cpp
@@ -1,26 +1,15 @@
-// RUN: %check_clang_tidy %s fuchsia-default-arguments %t
+// RUN: %check_clang_tidy %s fuchsia-default-arguments-declarations %t
 
 int foo(int value = 5) { return value; }
-// CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
 // CHECK-FIXES: int foo(int value) { return value; }
 
-int f() {
-  foo();
-  // CHECK-NOTES: [[@LINE-1]]:3: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments]
-  // CHECK-NOTES: [[@LINE-7]]:9: note: default parameter was declared here
-}
-
 int bar(int value) { return value; }
 
-int n() {
-  foo(0);
-  bar(0);
-}
-
 class Baz {
 public:
   int a(int value = 5) { return value; }
-  // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
   // CHECK-FIXES: int a(int value) { return value; }
 
   int b(int value) { return value; }
@@ -29,7 +18,7 @@
 class Foo {
   // Fix should be suggested in declaration
   int a(int value = 53);
-  // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NOTES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
   // CHECK-FIXES: int a(int value);
 };
 
@@ -40,7 +29,7 @@
 
 // Elided functions
 void f(int = 5) {};
-// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
 // CHECK-FIXES: void f(int) {};
 
 void g(int) {};
@@ -49,12 +38,12 @@
 #define D(val) = val
 
 void h(int i D(5));
-// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
 // CHECK-FIXES-NOT: void h(int i);
 
 void x(int i);
 void x(int i = 12);
-// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
 // CHECK-FIXES: void x(int i);
 
 void x(int i) {}
@@ -64,17 +53,8 @@
 };
 
 void S::x(int i = 12) {}
-// CHECK-NOTES: [[@LINE-1]]:11: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-NOTES: [[@LINE-1]]:11: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments-declarations]
 // CHECK-FIXES: void S::x(int i) {}
 
 int 

[PATCH] D62559: [WebAssembly] Support VPtr sanitizer for Emscripten

2019-05-28 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:214
+  if (getTriple().isOSEmscripten()) {
+Res |= SanitizerKind::Vptr;
+  }

Does this mean we only support `Vptr` among sanitizers [[ 
https://github.com/llvm/llvm-project/blob/92d706eaca6cc79501066eae4392b68e52c1/clang/include/clang/Basic/Sanitizers.def#L76-L103
 | here ]]?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62559



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


[PATCH] D62005: [libunwind] [test] Fix inferring source paths

2019-05-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: libunwind/test/libunwind/test/config.py:27
+self.libcxx_src_root = (self.get_lit_conf('libcxx_src_root')
+or os.path.join(self.libunwind_src_root, '../libcxx'))
 

Can you use `os.path.join(self.libunwind_src_root, '..', 'libcxx')` to make it 
compatible with systems that don't use `/` as path separators?


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D62005



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


[PATCH] D61809: [BPF] Preserve debuginfo array/union/struct type/access index

2019-05-28 Thread Alexei Starovoitov via Phabricator via cfe-commits
ast accepted this revision.
ast added a comment.

lgtm


Repository:
  rC Clang

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

https://reviews.llvm.org/D61809



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


[PATCH] D61809: [BPF] Preserve debuginfo array/union/struct type/access index

2019-05-28 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 201793.
yonghong-song added a comment.

remove bpf offsetreloc option and use FileCheck in the test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61809

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuilder.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaChecking.cpp
  test/CodeGen/bpf-offsetreloc.c

Index: test/CodeGen/bpf-offsetreloc.c
===
--- /dev/null
+++ test/CodeGen/bpf-offsetreloc.c
@@ -0,0 +1,22 @@
+// RUN: %clang %s -target bpfeb -x c -emit-llvm -S -g -O2 -o - | FileCheck %s
+// RUN: %clang %s -target bpfel -x c -emit-llvm -S -g -O2 -o - | FileCheck %s
+
+struct t {
+  int i:1;
+  int j:2;
+  union {
+   int a;
+   int b;
+  } c[4];
+};
+
+#define _(x) (__builtin_preserve_access_index(x))
+
+void *test(struct t *arg) {
+  return _(>c[3].b);
+}
+
+// CHECK: llvm.preserve.struct.access.index
+// CHECK: llvm.preserve.array.access.index
+// CHECK: llvm.preserve.union.access.index
+// CHECK-NOT: __builtin_preserve_access_index
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -190,6 +190,16 @@
   return false;
 }
 
+/// Check the number of arguments, and set the result type to
+/// the argument type.
+static bool SemaBuiltinPreserveAI(Sema , CallExpr *TheCall) {
+  if (checkArgCount(S, TheCall, 1))
+return true;
+
+  TheCall->setType(TheCall->getArg(0)->getType());
+  return false;
+}
+
 static bool SemaBuiltinOverflow(Sema , CallExpr *TheCall) {
   if (checkArgCount(S, TheCall, 3))
 return true;
@@ -1407,6 +1417,10 @@
 TheCall->setType(Context.IntTy);
 break;
   }
+  case Builtin::BI__builtin_preserve_access_index:
+if (SemaBuiltinPreserveAI(*this, TheCall))
+  return ExprError();
+break;
   case Builtin::BI__builtin_call_with_static_chain:
 if (SemaBuiltinCallWithStaticChain(*this, TheCall))
   return ExprError();
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1028,6 +1028,10 @@
 store->setAlignment(addr.getAlignment().getQuantity());
   }
 
+  /// isPreserveDIAccessIndexNeeded - Return true if it is needed to
+  /// preserve the Debuginfo access index.
+  bool isPreserveDIAccessIndexNeeded(const Expr *E);
+
   /// An RAII object to record that we're evaluating a statement
   /// expression.
   class StmtExprEvaluation {
@@ -3559,7 +3563,8 @@
 
   llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
   const ObjCIvarDecl *Ivar);
-  LValue EmitLValueForField(LValue Base, const FieldDecl* Field);
+  LValue EmitLValueForField(LValue Base, const FieldDecl* Field,
+const Expr *E = nullptr);
   LValue EmitLValueForLambdaField(const FieldDecl *Field);
 
   /// EmitLValueForFieldInitialization - Like EmitLValueForField, except that
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -25,6 +25,7 @@
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/NSAPI.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
@@ -649,6 +650,52 @@
  SanOpts.has(SanitizerKind::Vptr);
 }
 
+/// The expression E is a candidate for preserving debuginfo access index
+/// if it is inside an __builtin_preserve_access_index intrinsic call.
+bool CodeGenFunction::isPreserveDIAccessIndexNeeded(const Expr *E) {
+  if (!E)
+return false;
+
+  if (!getDebugInfo())
+return false;
+
+  while (true) {
+const auto  = getContext().getParents(*E);
+if (Parents.size() != 1)
+  return false;
+
+E = Parents[0].get();
+if (!E)
+  return false;
+
+// Check whether E is a BI__builtin_preserve_access_index
+// intrinsic call.
+const auto *CE = dyn_cast(E);
+if (CE) {
+  // Callee must a builtin function.
+  const Expr *Callee = CE->getCallee()->IgnoreParens();
+  auto ICE = dyn_cast(Callee);
+  if (!ICE)
+return false;
+  if (ICE->getCastKind() != CK_BuiltinFnToFnPtr)
+return false;
+
+  auto DRE = dyn_cast(ICE->getSubExpr());
+  if (!DRE)
+return false;
+
+  if (auto FD = dyn_cast(DRE->getDecl())) {
+if (FD->getBuiltinID() == Builtin::BI__builtin_preserve_access_index)
+  return true;
+  }
+
+  break;
+}
+  }
+
+  return false;
+}
+
 void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc,
 llvm::Value *Ptr, QualType Ty,
 

[PATCH] D62509: [Driver] Render -fuse-init-array for -fembed-bitcode

2019-05-28 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:3675
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+

Hmm, what other arguments will this render into the option handling that we 
weren't handling before?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62509



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


[PATCH] D62558: [Driver] Search the toolchain dir with -print-file-name

2019-05-28 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361903: [Driver] Search the toolchain dir with 
-print-file-name (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62558?vs=201788=201791#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62558

Files:
  lib/Driver/Driver.cpp
  test/Driver/print-file-name.c


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -4437,6 +4437,11 @@
   if (llvm::sys::fs::exists(Twine(P)))
 return P.str();
 
+  SmallString<128> D(Dir);
+  llvm::sys::path::append(D, "..", Name);
+  if (llvm::sys::fs::exists(Twine(D)))
+return D.str();
+
   if (auto P = SearchPaths(TC.getLibraryPaths()))
 return *P;
 
Index: test/Driver/print-file-name.c
===
--- test/Driver/print-file-name.c
+++ test/Driver/print-file-name.c
@@ -0,0 +1,19 @@
+// Test that -print-file-name finds the correct file.
+
+// RUN: %clang -print-file-name=share/asan_blacklist.txt 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-RESOURCE-DIR %s
+// CHECK-RESOURCE-DIR: resource_dir{{/|}}share{{/|}}asan_blacklist.txt
+
+// RUN: %clang -print-file-name=libclang_rt.builtins.a 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-COMPILER-RT %s
+// CHECK-COMPILER-RT: 
resource_dir_with_per_target_subdir{{/|}}lib{{/|}}x86_64-linux-gnu{{/|}}libclang_rt.builtins.a
+
+// RUN: %clang -print-file-name=include/c++/v1 2>&1 \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-INSTALL-DIR %s
+// CHECK-INSTALL-DIR: 
basic_linux_libcxx_tree{{/|}}usr{{/|}}bin{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -4437,6 +4437,11 @@
   if (llvm::sys::fs::exists(Twine(P)))
 return P.str();
 
+  SmallString<128> D(Dir);
+  llvm::sys::path::append(D, "..", Name);
+  if (llvm::sys::fs::exists(Twine(D)))
+return D.str();
+
   if (auto P = SearchPaths(TC.getLibraryPaths()))
 return *P;
 
Index: test/Driver/print-file-name.c
===
--- test/Driver/print-file-name.c
+++ test/Driver/print-file-name.c
@@ -0,0 +1,19 @@
+// Test that -print-file-name finds the correct file.
+
+// RUN: %clang -print-file-name=share/asan_blacklist.txt 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-RESOURCE-DIR %s
+// CHECK-RESOURCE-DIR: resource_dir{{/|}}share{{/|}}asan_blacklist.txt
+
+// RUN: %clang -print-file-name=libclang_rt.builtins.a 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-COMPILER-RT %s
+// CHECK-COMPILER-RT: resource_dir_with_per_target_subdir{{/|}}lib{{/|}}x86_64-linux-gnu{{/|}}libclang_rt.builtins.a
+
+// RUN: %clang -print-file-name=include/c++/v1 2>&1 \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-INSTALL-DIR %s
+// CHECK-INSTALL-DIR: basic_linux_libcxx_tree{{/|}}usr{{/|}}bin{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r361903 - [Driver] Search the toolchain dir with -print-file-name

2019-05-28 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue May 28 17:01:05 2019
New Revision: 361903

URL: http://llvm.org/viewvc/llvm-project?rev=361903=rev
Log:
[Driver] Search the toolchain dir with -print-file-name

This is useful when looking for directories or files relative to the
toolchain root, e.g. include/c++/v1. This change also adds a test
to make sure this functionality doesn't regress in the future.

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

Added:
cfe/trunk/test/Driver/print-file-name.c
Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=361903=361902=361903=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue May 28 17:01:05 2019
@@ -4437,6 +4437,11 @@ std::string Driver::GetFilePath(StringRe
   if (llvm::sys::fs::exists(Twine(P)))
 return P.str();
 
+  SmallString<128> D(Dir);
+  llvm::sys::path::append(D, "..", Name);
+  if (llvm::sys::fs::exists(Twine(D)))
+return D.str();
+
   if (auto P = SearchPaths(TC.getLibraryPaths()))
 return *P;
 

Added: cfe/trunk/test/Driver/print-file-name.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/print-file-name.c?rev=361903=auto
==
--- cfe/trunk/test/Driver/print-file-name.c (added)
+++ cfe/trunk/test/Driver/print-file-name.c Tue May 28 17:01:05 2019
@@ -0,0 +1,19 @@
+// Test that -print-file-name finds the correct file.
+
+// RUN: %clang -print-file-name=share/asan_blacklist.txt 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-RESOURCE-DIR %s
+// CHECK-RESOURCE-DIR: resource_dir{{/|}}share{{/|}}asan_blacklist.txt
+
+// RUN: %clang -print-file-name=libclang_rt.builtins.a 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-COMPILER-RT %s
+// CHECK-COMPILER-RT: 
resource_dir_with_per_target_subdir{{/|}}lib{{/|}}x86_64-linux-gnu{{/|}}libclang_rt.builtins.a
+
+// RUN: %clang -print-file-name=include/c++/v1 2>&1 \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-INSTALL-DIR %s
+// CHECK-INSTALL-DIR: 
basic_linux_libcxx_tree{{/|}}usr{{/|}}bin{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1


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


[PATCH] D62559: [WebAssembly] Support VPtr sanitizer for Emscripten

2019-05-28 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum created this revision.
quantum added reviewers: tlively, aheejin.
Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100, 
dschuff.
Herald added a project: clang.

After https://github.com/emscripten-core/emscripten/pull/8651, Emscripten
supports the full UBSan runtime. This includes the VPtr sanitizer.

This diff allows clang to generate code that uses the VPtr sanitizer for
Emscripten.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62559

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


Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -66,6 +66,7 @@
   llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
+  SanitizerMask getSupportedSanitizers() const override;
 
   const char *getDefaultLinker() const override { return "wasm-ld"; }
 
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -208,6 +208,14 @@
   }
 }
 
+SanitizerMask WebAssembly::getSupportedSanitizers() const {
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+  if (getTriple().isOSEmscripten()) {
+Res |= SanitizerKind::Vptr;
+  }
+  return Res;
+}
+
 Tool *WebAssembly::buildLinker() const {
   return new tools::wasm::Linker(*this);
 }


Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -66,6 +66,7 @@
   llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
+  SanitizerMask getSupportedSanitizers() const override;
 
   const char *getDefaultLinker() const override { return "wasm-ld"; }
 
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -208,6 +208,14 @@
   }
 }
 
+SanitizerMask WebAssembly::getSupportedSanitizers() const {
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+  if (getTriple().isOSEmscripten()) {
+Res |= SanitizerKind::Vptr;
+  }
+  return Res;
+}
+
 Tool *WebAssembly::buildLinker() const {
   return new tools::wasm::Linker(*this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62558: [Driver] Search the toolchain dir with -print-file-name

2019-05-28 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

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

https://reviews.llvm.org/D62558



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


[PATCH] D62558: [Driver] Search the toolchain dir with -print-file-name

2019-05-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, echristo.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is useful when looking for directories or files relative to the
toolchain root, e.g. include/c++/v1. This change also adds a test
to make sure this functionality doesn't regress in the future.


Repository:
  rC Clang

https://reviews.llvm.org/D62558

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/print-file-name.c


Index: clang/test/Driver/print-file-name.c
===
--- /dev/null
+++ clang/test/Driver/print-file-name.c
@@ -0,0 +1,19 @@
+// Test that -print-file-name finds the correct file.
+
+// RUN: %clang -print-file-name=share/asan_blacklist.txt 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-RESOURCE-DIR %s
+// CHECK-RESOURCE-DIR: resource_dir{{/|}}share{{/|}}asan_blacklist.txt
+
+// RUN: %clang -print-file-name=libclang_rt.builtins.a 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-COMPILER-RT %s
+// CHECK-COMPILER-RT: 
resource_dir_with_per_target_subdir{{/|}}lib{{/|}}x86_64-linux-gnu{{/|}}libclang_rt.builtins.a
+
+// RUN: %clang -print-file-name=include/c++/v1 2>&1 \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-INSTALL-DIR %s
+// CHECK-INSTALL-DIR: 
basic_linux_libcxx_tree{{/|}}usr{{/|}}bin{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4427,6 +4427,11 @@
   if (auto P = SearchPaths(PrefixDirs))
 return *P;
 
+  SmallString<128> D(Dir);
+  llvm::sys::path::append(D, "..", Name);
+  if (llvm::sys::fs::exists(Twine(D)))
+return D.str();
+
   SmallString<128> R(ResourceDir);
   llvm::sys::path::append(R, Name);
   if (llvm::sys::fs::exists(Twine(R)))


Index: clang/test/Driver/print-file-name.c
===
--- /dev/null
+++ clang/test/Driver/print-file-name.c
@@ -0,0 +1,19 @@
+// Test that -print-file-name finds the correct file.
+
+// RUN: %clang -print-file-name=share/asan_blacklist.txt 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-RESOURCE-DIR %s
+// CHECK-RESOURCE-DIR: resource_dir{{/|}}share{{/|}}asan_blacklist.txt
+
+// RUN: %clang -print-file-name=libclang_rt.builtins.a 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-COMPILER-RT %s
+// CHECK-COMPILER-RT: resource_dir_with_per_target_subdir{{/|}}lib{{/|}}x86_64-linux-gnu{{/|}}libclang_rt.builtins.a
+
+// RUN: %clang -print-file-name=include/c++/v1 2>&1 \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
+// RUN: --target=x86_64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-INSTALL-DIR %s
+// CHECK-INSTALL-DIR: basic_linux_libcxx_tree{{/|}}usr{{/|}}bin{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4427,6 +4427,11 @@
   if (auto P = SearchPaths(PrefixDirs))
 return *P;
 
+  SmallString<128> D(Dir);
+  llvm::sys::path::append(D, "..", Name);
+  if (llvm::sys::fs::exists(Twine(D)))
+return D.str();
+
   SmallString<128> R(ResourceDir);
   llvm::sys::path::append(R, Name);
   if (llvm::sys::fs::exists(Twine(R)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60499: [ASTImporter] Various source location and range import fixes.

2019-05-28 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I don't see any regressions but I am a little uncomfortable since there are no 
tests. So I would feel better if this was split into three parts: Namespaces, 
Enums and Templates.

Are there small test programs that fail due to the missing data? We can add 
them as regression tests.




Comment at: lib/AST/ASTImporter.cpp:6129
 if (Error Err =
-ImportTemplateArgumentListInfo(E->template_arguments(), ToTAInfo))
+ImportTemplateArgumentListInfo(E->getLAngleLoc(), 
E->getRAngleLoc(),
+   E->template_arguments(), ToTAInfo))

Curious why you decided to add the new arguments to the front as opposed to the 
end?



Comment at: lib/AST/ASTImporter.cpp:7150
+  auto Imp = importSeq(E->getQualifierLoc(), E->getTemplateKeywordLoc(),
+   E->getDeclName(), E->getNameInfo().getLoc(),
+   E->getLAngleLoc(), E->getRAngleLoc());

Can you explain why `E->getNameInfo().getLoc()` is more correct than 
`E->getExprLoc()`?



Comment at: lib/AST/ASTImporter.cpp:7225
 
-  if (E->hasExplicitTemplateArgs() && E->getTemplateKeywordLoc().isValid()) {
+  if (E->hasExplicitTemplateArgs()) {
 TemplateArgumentListInfo ToTAInfo;

We still want to import a few lines down even if 
`!E->getTemplateKeywordLoc().isValid()`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60499



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


[PATCH] D62557: [analyzer] Modernize CStringChecker to use CallDescriptions.

2019-05-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet.
Herald added a project: clang.
NoQ added parent revisions: D62556: [analyzer] NFC: CallDescription: Implement 
describing C library functions., D62440: [analyzer] NFC: Change evalCall() to 
provide a CallEvent..

This uses the new `CDF_MaybeBuiltin` flag to handle C library functions. It's 
mostly a refactoring pass, but it does fix a bug in handling `memset()` when it 
expands to `__builtin___memset_chk()` because the latter has one more argument 
and `memset()` handling code was trying to match the exact number of arguments.


Repository:
  rC Clang

https://reviews.llvm.org/D62557

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

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -1598,3 +1598,9 @@
   memset(, 0, sizeof(short));
   clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
 }
+
+void test_memset_chk() {
+  int x;
+  __builtin___memset_chk(, 0, sizeof(x), __builtin_object_size(, 0));
+  clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -73,7 +73,38 @@
 
   typedef void (CStringChecker::*FnCheck)(CheckerContext &,
   const CallExpr *) const;
+  CallDescriptionMap Callbacks = {
+  {{CDF_MaybeBuiltin, "memcpy", 3}, ::evalMemcpy},
+  {{CDF_MaybeBuiltin, "mempcpy", 3}, ::evalMempcpy},
+  {{CDF_MaybeBuiltin, "memcmp", 3}, ::evalMemcmp},
+  {{CDF_MaybeBuiltin, "memmove", 3}, ::evalMemmove},
+  {{CDF_MaybeBuiltin, "memset", 3}, ::evalMemset},
+  {{CDF_MaybeBuiltin, "explicit_memset", 3}, ::evalMemset},
+  {{CDF_MaybeBuiltin, "strcpy", 2}, ::evalStrcpy},
+  {{CDF_MaybeBuiltin, "strncpy", 3}, ::evalStrncpy},
+  {{CDF_MaybeBuiltin, "stpcpy", 2}, ::evalStpcpy},
+  {{CDF_MaybeBuiltin, "strlcpy", 3}, ::evalStrlcpy},
+  {{CDF_MaybeBuiltin, "strcat", 2}, ::evalStrcat},
+  {{CDF_MaybeBuiltin, "strncat", 3}, ::evalStrncat},
+  {{CDF_MaybeBuiltin, "strlcat", 3}, ::evalStrlcat},
+  {{CDF_MaybeBuiltin, "strlen", 1}, ::evalstrLength},
+  {{CDF_MaybeBuiltin, "strnlen", 2}, ::evalstrnLength},
+  {{CDF_MaybeBuiltin, "strcmp", 2}, ::evalStrcmp},
+  {{CDF_MaybeBuiltin, "strncmp", 3}, ::evalStrncmp},
+  {{CDF_MaybeBuiltin, "strcasecmp", 2}, ::evalStrcasecmp},
+  {{CDF_MaybeBuiltin, "strncasecmp", 3}, ::evalStrncasecmp},
+  {{CDF_MaybeBuiltin, "strsep", 2}, ::evalStrsep},
+  {{CDF_MaybeBuiltin, "bcopy", 3}, ::evalBcopy},
+  {{CDF_MaybeBuiltin, "bcmp", 3}, ::evalMemcmp},
+  {{CDF_MaybeBuiltin, "bzero", 2}, ::evalBzero},
+  {{CDF_MaybeBuiltin, "explicit_bzero", 2}, ::evalBzero},
+  };
+
+  // These require a bit of special handling.
+  CallDescription StdCopy{{"std", "copy"}, 3},
+  StdCopyBackward{{"std", "copy_backward"}, 3};
 
+  FnCheck identifyCall(const CallEvent , CheckerContext ) const;
   void evalMemcpy(CheckerContext , const CallExpr *CE) const;
   void evalMempcpy(CheckerContext , const CallExpr *CE) const;
   void evalMemmove(CheckerContext , const CallExpr *CE) const;
@@ -1201,9 +1232,6 @@
 
 
 void CStringChecker::evalMemcpy(CheckerContext , const CallExpr *CE) const {
-  if (CE->getNumArgs() < 3)
-return;
-
   // void *memcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is the address of the destination buffer.
   const Expr *Dest = CE->getArg(0);
@@ -1213,9 +1241,6 @@
 }
 
 void CStringChecker::evalMempcpy(CheckerContext , const CallExpr *CE) const {
-  if (CE->getNumArgs() < 3)
-return;
-
   // void *mempcpy(void *restrict dst, const void *restrict src, size_t n);
   // The return value is a pointer to the byte following the last written byte.
   const Expr *Dest = CE->getArg(0);
@@ -1225,9 +1250,6 @@
 }
 
 void CStringChecker::evalMemmove(CheckerContext , const CallExpr *CE) const {
-  if (CE->getNumArgs() < 3)
-return;
-
   // void *memmove(void *dst, const void *src, size_t n);
   // The return value is the address of the destination buffer.
   const Expr *Dest = CE->getArg(0);
@@ -1237,18 +1259,12 @@
 }
 
 void CStringChecker::evalBcopy(CheckerContext , const CallExpr *CE) const {
-  if (CE->getNumArgs() < 3)
-return;
-
   // void bcopy(const void *src, void *dst, size_t n);
   evalCopyCommon(C, CE, C.getState(),
  CE->getArg(2), CE->getArg(1), CE->getArg(0));
 }
 
 void CStringChecker::evalMemcmp(CheckerContext , const CallExpr *CE) const {
-  if 

[PATCH] D62133: test/CodeGen/builtin-stackaddress.c duplicates test/CodeGen/2004-02-13-BuiltinFrameReturnAddress.c

2019-05-28 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62133



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


[PATCH] D62556: [analyzer] NFC: CallDescription: Implement describing C library functions.

2019-05-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet.
Herald added a project: clang.
NoQ added a parent revision: D62441: [analyzer] NFC: Introduce a convenient 
CallDescriptionMap class..

When matching C standard library functions in the checker, it's easy to forget 
that they are often implemented as macros that are expanded to compiler 
builtins. Such builtins would have a different name, so matching the callee 
identifier would fail, or may sometimes have more arguments than expected (so 
matching the exact number of arguments would fail, but this is fine as long as 
we have all the arguments that we need in their respective places.

This patch adds a set of flags to the `CallDescription` class so that to handle 
various special matching rules, and adds the first flag into this set, which 
enables a more fuzzy matching for functions that may be implemented as builtins.


Repository:
  rC Clang

https://reviews.llvm.org/D62556

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp

Index: clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
===
--- clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
+++ clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
@@ -102,6 +102,16 @@
   {{"foo"}, true},
   }), "void foo(); struct bar { void foo(); }; void test() { foo(); }"));
 
+  EXPECT_TRUE(tooling::runToolOnCode(
+  new CallDescriptionAction({
+  {{"memset", 3}, false},
+  {{CDF_MaybeBuiltin, "memset", 3}, true}
+  }),
+  "void foo() {"
+  "  int x;"
+  "  __builtin___memset_chk(, 0, sizeof(x),"
+  " __builtin_object_size(, 0));"
+  "}"));
 }
 
 } // namespace
Index: clang/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -356,20 +356,33 @@
   // FIXME: Add ObjC Message support.
   if (getKind() == CE_ObjCMessage)
 return false;
+
+  const IdentifierInfo *II = getCalleeIdentifier();
+  if (!II)
+return false;
+  const FunctionDecl *FD = dyn_cast_or_null(getDecl());
+  if (!FD)
+return false;
+
+  if (CD.Flags & CDF_MaybeBuiltin) {
+return CheckerContext::isCLibraryFunction(FD, CD.getFunctionName()) &&
+   (CD.RequiredArgs == CallDescription::NoArgRequirement ||
+CD.RequiredArgs <= getNumArgs());
+  }
+
   if (!CD.IsLookupDone) {
 CD.IsLookupDone = true;
 CD.II = ()->getStateManager().getContext().Idents.get(
 CD.getFunctionName());
   }
-  const IdentifierInfo *II = getCalleeIdentifier();
+
   if (!II || II != CD.II)
 return false;
 
-  const Decl *D = getDecl();
   // If CallDescription provides prefix names, use them to improve matching
   // accuracy.
-  if (CD.QualifiedName.size() > 1 && D) {
-const DeclContext *Ctx = D->getDeclContext();
+  if (CD.QualifiedName.size() > 1 && FD) {
+const DeclContext *Ctx = FD->getDeclContext();
 // See if we'll be able to match them all.
 size_t NumUnmatched = CD.QualifiedName.size() - 1;
 for (; Ctx && isa(Ctx); Ctx = Ctx->getParent()) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -1044,6 +1044,14 @@
   }
 };
 
+enum CallDescriptionFlags : int {
+  /// Describes a C standard function that is sometimes implemented as a macro
+  /// that expands to a compiler builtin with some __builtin prefix.
+  /// The builtin may as well have a few extra arguments on top of the requested
+  /// number of arguments.
+  CDF_MaybeBuiltin = 1 << 0,
+};
+
 /// This class represents a description of a function call using the number of
 /// arguments and the name of the function.
 class CallDescription {
@@ -1055,11 +1063,14 @@
   // e.g. "{a, b}" represent the qualified names, like "a::b".
   std::vector QualifiedName;
   unsigned RequiredArgs;
+  int Flags;
 
 public:
   const static unsigned NoArgRequirement = std::numeric_limits::max();
 
   /// Constructs a CallDescription object.
+  /// @param Flags A bitwise-or of CallDescriptionFlags that tweak
+  /// the matching behavior of the CallDescription object.
   ///
   /// @param QualifiedName The list of the name qualifiers of the function that
   /// will be matched. The user is allowed to skip any of the qualifiers.
@@ -1069,9 +1080,15 @@
   /// @param RequiredArgs The number of arguments that is expected to match a
   /// call. 

[PATCH] D62440: [analyzer] NFC: Change evalCall() to provide a CallEvent.

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



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:372
   CheckerContext ) const {
-  const FunctionDecl *FD = dyn_cast_or_null(CE->getCalleeDecl());
+  const auto *FD = dyn_cast_or_null(Call.getDecl());
   if (!FD)

a_sidorin wrote:
> Should we create helpers similar to getDecl() and getOriginExpr 
> (getFunctionDecl/getCallExpr)?
Generally it sounds like a good idea, but in the context of this patch it's 
only useful when i don't want to refactor the code to avoid needing such 
getters in the first place. Once the `CallDescription` interface is good 
enough, all such getters will turn into hard casts without null checks. But 
these two checkers implement their own custom call description facility, so 
they need this sort of dancing.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62440



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


[PATCH] D62435: Add Attribute NoThrow as an Exception Specifier Type

2019-05-28 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.

Seems fine to me; please wait for @aaron.ballman's review to conclude as well.


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

https://reviews.llvm.org/D62435



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


r361897 - [X86] Fix the Sema checks for getmant builtins to only allow 4 and 8 for rounding immediates.

2019-05-28 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 28 16:26:22 2019
New Revision: 361897

URL: http://llvm.org/viewvc/llvm-project?rev=361897=rev
Log:
[X86] Fix the Sema checks for getmant builtins to only allow 4 and 8 for 
rounding immediates.

These don't support embedded rounding so we shouldn't be setting HasRC. That 
way we only
allow current direction and suppress all exceptions.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/builtins-x86.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=361897=361896=361897=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue May 28 16:26:22 2019
@@ -3378,6 +3378,8 @@ bool Sema::CheckX86BuiltinRoundingOrSAE(
   case X86::BI__builtin_ia32_cvtss2sd_round_mask:
   case X86::BI__builtin_ia32_getexpsd128_round_mask:
   case X86::BI__builtin_ia32_getexpss128_round_mask:
+  case X86::BI__builtin_ia32_getmantpd512_mask:
+  case X86::BI__builtin_ia32_getmantps512_mask:
   case X86::BI__builtin_ia32_maxsd_round_mask:
   case X86::BI__builtin_ia32_maxss_round_mask:
   case X86::BI__builtin_ia32_minsd_round_mask:
@@ -3400,6 +3402,8 @@ bool Sema::CheckX86BuiltinRoundingOrSAE(
   case X86::BI__builtin_ia32_fixupimmsd_maskz:
   case X86::BI__builtin_ia32_fixupimmss_mask:
   case X86::BI__builtin_ia32_fixupimmss_maskz:
+  case X86::BI__builtin_ia32_getmantsd_round_mask:
+  case X86::BI__builtin_ia32_getmantss_round_mask:
   case X86::BI__builtin_ia32_rangepd512_mask:
   case X86::BI__builtin_ia32_rangeps512_mask:
   case X86::BI__builtin_ia32_rangesd128_round_mask:
@@ -3470,8 +3474,6 @@ bool Sema::CheckX86BuiltinRoundingOrSAE(
   case X86::BI__builtin_ia32_scalefps512_mask:
   case X86::BI__builtin_ia32_scalefsd_round_mask:
   case X86::BI__builtin_ia32_scalefss_round_mask:
-  case X86::BI__builtin_ia32_getmantpd512_mask:
-  case X86::BI__builtin_ia32_getmantps512_mask:
   case X86::BI__builtin_ia32_cvtsd2ss_round_mask:
   case X86::BI__builtin_ia32_sqrtsd_round_mask:
   case X86::BI__builtin_ia32_sqrtss_round_mask:
@@ -3500,11 +3502,6 @@ bool Sema::CheckX86BuiltinRoundingOrSAE(
 ArgNum = 4;
 HasRC = true;
 break;
-  case X86::BI__builtin_ia32_getmantsd_round_mask:
-  case X86::BI__builtin_ia32_getmantss_round_mask:
-ArgNum = 5;
-HasRC = true;
-break;
   }
 
   llvm::APSInt Result;

Modified: cfe/trunk/test/Sema/builtins-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins-x86.c?rev=361897=361896=361897=diff
==
--- cfe/trunk/test/Sema/builtins-x86.c (original)
+++ cfe/trunk/test/Sema/builtins-x86.c Tue May 28 16:26:22 2019
@@ -81,6 +81,14 @@ __mmask16 test__builtin_ia32_cmpps512_ma
   return __builtin_ia32_cmpps512_mask(__a, __b, 0, __u, 0); // expected-error 
{{invalid rounding argument}}
 }
 
+__m512 test__builtin_ia32_getmantps512_mask(__m512 a, __m512 b) {
+  return __builtin_ia32_getmantps512_mask(a, 0, b, (__mmask16)-1, 10); // 
expected-error {{invalid rounding argument}}
+}
+
+__m128 test__builtin_ia32_getmantss_round_mask(__m128 a, __m128 b, __m128 c) {
+  return __builtin_ia32_getmantss_round_mask(a, b, 0, c, (__mmask8)-1, 10); // 
expected-error {{invalid rounding argument}}
+}
+
 __m128i test_mm_mask_i32gather_epi32(__m128i a, int const *b, __m128i c, 
__m128i mask) {
   return __builtin_ia32_gatherd_d(a, b, c, mask, 5); // expected-error {{scale 
argument must be 1, 2, 4, or 8}}
 }


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


r361895 - Fix r361893 to also update a recently-added test.

2019-05-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 28 16:20:52 2019
New Revision: 361895

URL: http://llvm.org/viewvc/llvm-project?rev=361895=rev
Log:
Fix r361893 to also update a recently-added test.

Modified:
cfe/trunk/test/AST/ast-dump-expr-json.cpp

Modified: cfe/trunk/test/AST/ast-dump-expr-json.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-expr-json.cpp?rev=361895=361894=361895=diff
==
--- cfe/trunk/test/AST/ast-dump-expr-json.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-expr-json.cpp Tue May 28 16:20:52 2019
@@ -3854,31 +3854,6 @@ void TestNonADLCall3() {
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "FieldDecl",
-// CHECK-NEXT:"loc": {
-// CHECK-NEXT: "col": 8,
-// CHECK-NEXT: "file": "{{.*}}",
-// CHECK-NEXT: "line": 98
-// CHECK-NEXT:},
-// CHECK-NEXT:"range": {
-// CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "col": 8,
-// CHECK-NEXT:  "file": "{{.*}}",
-// CHECK-NEXT:  "line": 98
-// CHECK-NEXT: },
-// CHECK-NEXT: "end": {
-// CHECK-NEXT:  "col": 8,
-// CHECK-NEXT:  "file": "{{.*}}",
-// CHECK-NEXT:  "line": 98
-// CHECK-NEXT: }
-// CHECK-NEXT:},
-// CHECK-NEXT:"isImplicit": true,
-// CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": "V *"
-// CHECK-NEXT:}
-// CHECK-NEXT:   },
-// CHECK-NEXT:   {
-// CHECK-NEXT:"id": "0x{{.*}}",
 // CHECK-NEXT:"kind": "CXXMethodDecl",
 // CHECK-NEXT:"loc": {
 // CHECK-NEXT: "col": 7,
@@ -3920,6 +3895,31 @@ void TestNonADLCall3() {
 // CHECK-NEXT:  }
 // CHECK-NEXT: }
 // CHECK-NEXT:]
+// CHECK-NEXT:   },
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "FieldDecl",
+// CHECK-NEXT:"loc": {
+// CHECK-NEXT: "col": 8,
+// CHECK-NEXT: "file": "{{.*}}",
+// CHECK-NEXT: "line": 98
+// CHECK-NEXT:},
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "col": 8,
+// CHECK-NEXT:  "file": "{{.*}}",
+// CHECK-NEXT:  "line": 98
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "col": 8,
+// CHECK-NEXT:  "file": "{{.*}}",
+// CHECK-NEXT:  "line": 98
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"isImplicit": true,
+// CHECK-NEXT:"type": {
+// CHECK-NEXT: "qualType": "V *"
+// CHECK-NEXT:}
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: },
@@ -4043,31 +4043,6 @@ void TestNonADLCall3() {
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "FieldDecl",
-// CHECK-NEXT:"loc": {
-// CHECK-NEXT: "col": 8,
-// CHECK-NEXT: "file": "{{.*}}",
-// CHECK-NEXT: "line": 99
-// CHECK-NEXT:},
-// CHECK-NEXT:"range": {
-// CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "col": 8,
-// CHECK-NEXT:  "file": "{{.*}}",
-// CHECK-NEXT:  "line": 99
-// CHECK-NEXT: },
-// CHECK-NEXT: "end": {
-// CHECK-NEXT:  "col": 8,
-// CHECK-NEXT:  "file": "{{.*}}",
-// CHECK-NEXT:  "line": 99
-// CHECK-NEXT: }
-// CHECK-NEXT:},
-// CHECK-NEXT:"isImplicit": true,
-// CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": "V"
-// CHECK-NEXT:}
-// CHECK-NEXT:   },
-// CHECK-NEXT:   {
-// CHECK-NEXT:"id": "0x{{.*}}",
 // CHECK-NEXT:"kind": "CXXMethodDecl",
 // CHECK-NEXT:"loc": {
 // CHECK-NEXT: 

r361890 - Move code to mark a variable as odr-used adjacement to all the related

2019-05-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 28 16:09:42 2019
New Revision: 361890

URL: http://llvm.org/viewvc/llvm-project?rev=361890=rev
Log:
Move code to mark a variable as odr-used adjacement to all the related
code.

No functional change intended.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Sema/SemaInternal.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=361890=361889=361890=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue May 28 16:09:42 2019
@@ -4165,6 +4165,8 @@ public:
   void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var);
   void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
   void MarkMemberReferenced(MemberExpr *E);
+  void MarkCaptureUsedInEnclosingContext(VarDecl *Capture, SourceLocation Loc,
+ unsigned CapturingScopeIndex);
 
   void UpdateMarkingForLValueToRValue(Expr *E);
   void CleanupVarDeclMarking();

Modified: cfe/trunk/include/clang/Sema/SemaInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/SemaInternal.h?rev=361890=361889=361890=diff
==
--- cfe/trunk/include/clang/Sema/SemaInternal.h (original)
+++ cfe/trunk/include/clang/Sema/SemaInternal.h Tue May 28 16:09:42 2019
@@ -59,36 +59,6 @@ inline bool DeclAttrsMatchCUDAMode(const
   return isDeviceSideDecl == LangOpts.CUDAIsDevice;
 }
 
-// Directly mark a variable odr-used. Given a choice, prefer to use
-// MarkVariableReferenced since it does additional checks and then
-// calls MarkVarDeclODRUsed.
-// If the variable must be captured:
-//  - if FunctionScopeIndexToStopAt is null, capture it in the CurContext
-//  - else capture it in the DeclContext that maps to the
-//*FunctionScopeIndexToStopAt on the FunctionScopeInfo stack.
-inline void MarkVarDeclODRUsed(VarDecl *Var,
-SourceLocation Loc, Sema ,
-const unsigned *const FunctionScopeIndexToStopAt) {
-  // Keep track of used but undefined variables.
-  // FIXME: We shouldn't suppress this warning for static data members.
-  if (Var->hasDefinition(SemaRef.Context) == VarDecl::DeclarationOnly &&
-  (!Var->isExternallyVisible() || Var->isInline() ||
-   SemaRef.isExternalWithNoLinkageType(Var)) &&
-  !(Var->isStaticDataMember() && Var->hasInit())) {
-SourceLocation  = SemaRef.UndefinedButUsed[Var->getCanonicalDecl()];
-if (old.isInvalid())
-  old = Loc;
-  }
-  QualType CaptureType, DeclRefType;
-  SemaRef.tryCaptureVariable(Var, Loc, Sema::TryCapture_Implicit,
-/*EllipsisLoc*/ SourceLocation(),
-/*BuildAndDiagnose*/ true,
-CaptureType, DeclRefType,
-FunctionScopeIndexToStopAt);
-
-  Var->markUsed(SemaRef.Context);
-}
-
 /// Return a DLL attribute from the declaration.
 inline InheritableAttr *getDLLAttr(Decl *D) {
   assert(!(D->hasAttr() && D->hasAttr()) &&

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=361890=361889=361890=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue May 28 16:09:42 2019
@@ -15013,6 +15013,42 @@ void Sema::MarkFunctionReferenced(Source
   }
 }
 
+/// Directly mark a variable odr-used. Given a choice, prefer to use
+/// MarkVariableReferenced since it does additional checks and then
+/// calls MarkVarDeclODRUsed.
+/// If the variable must be captured:
+///  - if FunctionScopeIndexToStopAt is null, capture it in the CurContext
+///  - else capture it in the DeclContext that maps to the
+///*FunctionScopeIndexToStopAt on the FunctionScopeInfo stack.
+static void
+MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema ,
+   const unsigned *const FunctionScopeIndexToStopAt) {
+  // Keep track of used but undefined variables.
+  // FIXME: We shouldn't suppress this warning for static data members.
+  if (Var->hasDefinition(SemaRef.Context) == VarDecl::DeclarationOnly &&
+  (!Var->isExternallyVisible() || Var->isInline() ||
+   SemaRef.isExternalWithNoLinkageType(Var)) &&
+  !(Var->isStaticDataMember() && Var->hasInit())) {
+SourceLocation  = SemaRef.UndefinedButUsed[Var->getCanonicalDecl()];
+if (old.isInvalid())
+  old = Loc;
+  }
+  QualType CaptureType, DeclRefType;
+  SemaRef.tryCaptureVariable(Var, Loc, Sema::TryCapture_Implicit,
+/*EllipsisLoc*/ SourceLocation(),
+/*BuildAndDiagnose*/ true,
+CaptureType, DeclRefType,
+FunctionScopeIndexToStopAt);
+
+  Var->markUsed(SemaRef.Context);
+}
+
+void Sema::MarkCaptureUsedInEnclosingContext(VarDecl *Capture,
+ 

r361891 - If capturing a variable fails, add a capture anyway (and mark it

2019-05-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 28 16:09:44 2019
New Revision: 361891

URL: http://llvm.org/viewvc/llvm-project?rev=361891=rev
Log:
If capturing a variable fails, add a capture anyway (and mark it
invalid) so that we can avoid repeated diagnostics for the same capture.

Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
cfe/trunk/test/Sema/captured-statements.c
cfe/trunk/test/SemaCXX/lambda-expressions.cpp
cfe/trunk/test/SemaObjCXX/capturing-flexible-array-in-block.mm

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=361891=361890=361891=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Tue May 28 16:09:44 2019
@@ -539,23 +539,28 @@ class Capture {
   /// the lambda.
   bool NonODRUsed = false;
 
+  /// Whether the capture is invalid (a capture was required but the entity is
+  /// non-capturable).
+  bool Invalid = false;
+
 public:
   Capture(VarDecl *Var, bool Block, bool ByRef, bool IsNested,
-  SourceLocation Loc, SourceLocation EllipsisLoc,
-  QualType CaptureType, Expr *Cpy)
+  SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType,
+  Expr *Cpy, bool Invalid)
   : VarAndNestedAndThis(Var, IsNested ? IsNestedCapture : 0),
 InitExprAndCaptureKind(
-Cpy, !Var ? Cap_VLA : Block ? Cap_Block : ByRef ? Cap_ByRef
-: Cap_ByCopy),
-Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType) {}
+Cpy, !Var ? Cap_VLA
+  : Block ? Cap_Block : ByRef ? Cap_ByRef : Cap_ByCopy),
+Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType),
+Invalid(Invalid) {}
 
   enum IsThisCapture { ThisCapture };
   Capture(IsThisCapture, bool IsNested, SourceLocation Loc,
-  QualType CaptureType, Expr *Cpy, const bool ByCopy)
+  QualType CaptureType, Expr *Cpy, const bool ByCopy, bool Invalid)
   : VarAndNestedAndThis(
 nullptr, (IsThisCaptured | (IsNested ? IsNestedCapture : 0))),
-InitExprAndCaptureKind(Cpy, ByCopy ? Cap_ByCopy : Cap_ByRef),
-Loc(Loc), CaptureType(CaptureType) {}
+InitExprAndCaptureKind(Cpy, ByCopy ? Cap_ByCopy : Cap_ByRef), Loc(Loc),
+CaptureType(CaptureType), Invalid(Invalid) {}
 
   bool isThisCapture() const {
 return VarAndNestedAndThis.getInt() & IsThisCaptured;
@@ -585,6 +590,8 @@ public:
 return VarAndNestedAndThis.getInt() & IsNestedCapture;
   }
 
+  bool isInvalid() const { return Invalid; }
+
   bool isODRUsed() const { return ODRUsed; }
   bool isNonODRUsed() const { return NonODRUsed; }
   void markUsed(bool IsODRUse) { (IsODRUse ? ODRUsed : NonODRUsed) = true; }
@@ -650,9 +657,9 @@ public:
 
   void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested,
   SourceLocation Loc, SourceLocation EllipsisLoc,
-  QualType CaptureType, Expr *Cpy) {
+  QualType CaptureType, Expr *Cpy, bool Invalid) {
 Captures.push_back(Capture(Var, isBlock, isByref, isNested, Loc,
-   EllipsisLoc, CaptureType, Cpy));
+   EllipsisLoc, CaptureType, Cpy, Invalid));
 CaptureMap[Var] = Captures.size();
   }
 
@@ -660,7 +667,7 @@ public:
 Captures.push_back(Capture(/*Var*/ nullptr, /*isBlock*/ false,
/*isByref*/ false, /*isNested*/ false, Loc,
/*EllipsisLoc*/ SourceLocation(), CaptureType,
-   /*Cpy*/ nullptr));
+   /*Cpy*/ nullptr, /*Invalid*/ false));
   }
 
   // Note, we do not need to add the type of 'this' since that is always
@@ -1016,7 +1023,7 @@ CapturingScopeInfo::addThisCapture(bool
Expr *Cpy,
const bool ByCopy) {
   Captures.push_back(Capture(Capture::ThisCapture, isNested, Loc, QualType(),
- Cpy, ByCopy));
+ Cpy, ByCopy, /*Invalid*/ false));
   CXXThisCaptureIndex = Captures.size();
 }
 

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=361891=361890=361891=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May 28 16:09:44 2019
@@ -12939,7 +12939,7 @@ static void RebuildLambdaScopeInfo(CXXMe
   /*RefersToEnclosingVariableOrCapture*/true, 

r361892 - Simplify clang::Capture. No functionality change intended.

2019-05-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 28 16:09:45 2019
New Revision: 361892

URL: http://llvm.org/viewvc/llvm-project?rev=361892=rev
Log:
Simplify clang::Capture. No functionality change intended.

We don't need to pack flags into the bottom bits of pointers here; we
have plenty of trailing bits in this type.

Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=361892=361891=361892=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Tue May 28 16:09:45 2019
@@ -506,20 +506,14 @@ class Capture {
   enum CaptureKind {
 Cap_ByCopy, Cap_ByRef, Cap_Block, Cap_VLA
   };
-  enum {
-IsNestedCapture = 0x1,
-IsThisCaptured = 0x2
-  };
 
-  /// The variable being captured (if we are not capturing 'this') and whether
-  /// this is a nested capture, and whether we are capturing 'this'
-  llvm::PointerIntPair VarAndNestedAndThis;
-
-  /// Expression to initialize a field of the given type, and the kind of
-  /// capture (if this is a capture and not an init-capture). The expression
-  /// is only required if we are capturing ByVal and the variable's type has
-  /// a non-trivial copy constructor.
-  llvm::PointerIntPair InitExprAndCaptureKind;
+  /// If !CapturesThis, the captured variable.
+  VarDecl *CapturedVar = nullptr;
+
+  /// Expression to initialize a field of the given type. This is only required
+  /// if we are capturing ByVal and the variable's type has a non-trivial copy
+  /// constructor.
+  Expr *InitExpr = nullptr;
 
   /// The source location at which the first capture occurred.
   SourceLocation Loc;
@@ -527,78 +521,77 @@ class Capture {
   /// The location of the ellipsis that expands a parameter pack.
   SourceLocation EllipsisLoc;
 
-  /// The type as it was captured, which is in effect the type of the
-  /// non-static data member that would hold the capture.
+  /// The type as it was captured, which is the type of the non-static data
+  /// member that would hold the capture.
   QualType CaptureType;
 
+  /// The CaptureKind of this capture.
+  unsigned Kind : 2;
+
+  /// Whether this is a nested capture (a capture of an enclosing capturing
+  /// scope's capture).
+  unsigned Nested : 1;
+
+  /// Whether this is a capture of '*this'.
+  unsigned CapturesThis : 1;
+
   /// Whether an explicit capture has been odr-used in the body of the
   /// lambda.
-  bool ODRUsed = false;
+  unsigned ODRUsed : 1;
 
   /// Whether an explicit capture has been non-odr-used in the body of
   /// the lambda.
-  bool NonODRUsed = false;
+  unsigned NonODRUsed : 1;
 
   /// Whether the capture is invalid (a capture was required but the entity is
   /// non-capturable).
-  bool Invalid = false;
+  unsigned Invalid : 1;
 
 public:
   Capture(VarDecl *Var, bool Block, bool ByRef, bool IsNested,
   SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType,
   Expr *Cpy, bool Invalid)
-  : VarAndNestedAndThis(Var, IsNested ? IsNestedCapture : 0),
-InitExprAndCaptureKind(
-Cpy, !Var ? Cap_VLA
-  : Block ? Cap_Block : ByRef ? Cap_ByRef : Cap_ByCopy),
-Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType),
-Invalid(Invalid) {}
+  : CapturedVar(Var), InitExpr(Cpy), Loc(Loc), EllipsisLoc(EllipsisLoc),
+CaptureType(CaptureType),
+Kind(!Var ? Cap_VLA
+  : Block ? Cap_Block : ByRef ? Cap_ByRef : Cap_ByCopy),
+Nested(IsNested), CapturesThis(false), ODRUsed(false),
+NonODRUsed(false), Invalid(Invalid) {}
 
   enum IsThisCapture { ThisCapture };
   Capture(IsThisCapture, bool IsNested, SourceLocation Loc,
   QualType CaptureType, Expr *Cpy, const bool ByCopy, bool Invalid)
-  : VarAndNestedAndThis(
-nullptr, (IsThisCaptured | (IsNested ? IsNestedCapture : 0))),
-InitExprAndCaptureKind(Cpy, ByCopy ? Cap_ByCopy : Cap_ByRef), Loc(Loc),
-CaptureType(CaptureType), Invalid(Invalid) {}
-
-  bool isThisCapture() const {
-return VarAndNestedAndThis.getInt() & IsThisCaptured;
-  }
+  : InitExpr(Cpy), Loc(Loc), CaptureType(CaptureType),
+Kind(ByCopy ? Cap_ByCopy : Cap_ByRef), Nested(IsNested),
+CapturesThis(true), ODRUsed(false), NonODRUsed(false),
+Invalid(Invalid) {}
 
+  bool isThisCapture() const { return CapturesThis; }
   bool isVariableCapture() const {
 return !isThisCapture() && !isVLATypeCapture();
   }
 
-  bool isCopyCapture() const {
-return InitExprAndCaptureKind.getInt() == Cap_ByCopy;
-  }
+  bool isCopyCapture() const { return Kind == Cap_ByCopy; }
+  bool isReferenceCapture() const { return Kind == Cap_ByRef; }
+  bool isBlockCapture() const { return Kind == Cap_Block; }
+  bool isVLATypeCapture() const { return Kind == 

r361893 - Defer creating fields for captures until we finish building the

2019-05-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 28 16:09:46 2019
New Revision: 361893

URL: http://llvm.org/viewvc/llvm-project?rev=361893=rev
Log:
Defer creating fields for captures until we finish building the
capturing expression or statement.

No functionality change yet. The intent is that we will also delay
building the initialization expression until the enclosing context, so
that:
a) we build the initialization expression in the right context, and
b) we can elide captures that are not odr-used, as suggested by P0588R1.

This also consolidates some duplicated code building capture fields into
a single place.

Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/ScopeInfo.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/AST/ast-dump-expr.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=361893=361892=361893=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Tue May 28 16:09:46 2019
@@ -507,8 +507,13 @@ class Capture {
 Cap_ByCopy, Cap_ByRef, Cap_Block, Cap_VLA
   };
 
-  /// If !CapturesThis, the captured variable.
-  VarDecl *CapturedVar = nullptr;
+  union {
+/// If Kind == Cap_VLA, the captured type.
+const VariableArrayType *CapturedVLA;
+
+/// Otherwise, the captured variable (if any).
+VarDecl *CapturedVar;
+  };
 
   /// Expression to initialize a field of the given type. This is only required
   /// if we are capturing ByVal and the variable's type has a non-trivial copy
@@ -553,8 +558,7 @@ public:
   Expr *Cpy, bool Invalid)
   : CapturedVar(Var), InitExpr(Cpy), Loc(Loc), EllipsisLoc(EllipsisLoc),
 CaptureType(CaptureType),
-Kind(!Var ? Cap_VLA
-  : Block ? Cap_Block : ByRef ? Cap_ByRef : Cap_ByCopy),
+Kind(Block ? Cap_Block : ByRef ? Cap_ByRef : Cap_ByCopy),
 Nested(IsNested), CapturesThis(false), ODRUsed(false),
 NonODRUsed(false), Invalid(Invalid) {}
 
@@ -566,6 +570,13 @@ public:
 CapturesThis(true), ODRUsed(false), NonODRUsed(false),
 Invalid(Invalid) {}
 
+  enum IsVLACapture { VLACapture };
+  Capture(IsVLACapture, const VariableArrayType *VLA, bool IsNested,
+  SourceLocation Loc, QualType CaptureType)
+  : CapturedVLA(VLA), Loc(Loc), CaptureType(CaptureType), Kind(Cap_VLA),
+Nested(IsNested), CapturesThis(false), ODRUsed(false),
+NonODRUsed(false), Invalid(false) {}
+
   bool isThisCapture() const { return CapturesThis; }
   bool isVariableCapture() const {
 return !isThisCapture() && !isVLATypeCapture();
@@ -594,6 +605,11 @@ public:
 return CapturedVar;
   }
 
+  const VariableArrayType *getCapturedVLAType() const {
+assert(isVLATypeCapture());
+return CapturedVLA;
+  }
+
   /// Retrieve the location at which this variable was captured.
   SourceLocation getLocation() const { return Loc; }
 
@@ -653,17 +669,13 @@ public:
 CaptureMap[Var] = Captures.size();
   }
 
-  void addVLATypeCapture(SourceLocation Loc, QualType CaptureType) {
-Captures.push_back(Capture(/*Var*/ nullptr, /*isBlock*/ false,
-   /*isByref*/ false, /*isNested*/ false, Loc,
-   /*EllipsisLoc*/ SourceLocation(), CaptureType,
-   /*Cpy*/ nullptr, /*Invalid*/ false));
+  void addVLATypeCapture(SourceLocation Loc, const VariableArrayType *VLAType,
+ QualType CaptureType) {
+Captures.push_back(Capture(Capture::VLACapture, VLAType,
+   /*FIXME: IsNested*/ false, Loc, CaptureType));
   }
 
-  // Note, we do not need to add the type of 'this' since that is always
-  // retrievable from Sema::getCurrentThisType - and is also encoded within the
-  // type of the corresponding FieldDecl.
-  void addThisCapture(bool isNested, SourceLocation Loc,
+  void addThisCapture(bool isNested, SourceLocation Loc, QualType CaptureType,
   Expr *Cpy, bool ByCopy);
 
   /// Determine whether the C++ 'this' is captured.
@@ -1010,9 +1022,9 @@ void FunctionScopeInfo::recordUseOfWeak(
 
 inline void
 CapturingScopeInfo::addThisCapture(bool isNested, SourceLocation Loc,
-   Expr *Cpy,
+   QualType CaptureType, Expr *Cpy,
const bool ByCopy) {
-  Captures.push_back(Capture(Capture::ThisCapture, isNested, Loc, QualType(),
+  Captures.push_back(Capture(Capture::ThisCapture, isNested, Loc, CaptureType,
  Cpy, ByCopy, /*Invalid*/ false));
   

[PATCH] D54187: Add debuginfo-tests that use cdb on Windows

2019-05-28 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361889: Add debuginfo-tests that use cdb on Windows 
(authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54187?vs=201779=201781#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54187

Files:
  debuginfo-tests/trunk/CMakeLists.txt
  debuginfo-tests/trunk/lit.cfg.py
  debuginfo-tests/trunk/lit.site.cfg.py.in
  debuginfo-tests/trunk/win_cdb/README.txt
  debuginfo-tests/trunk/win_cdb/hello.c
  debuginfo-tests/trunk/win_cdb/lit.local.cfg.py
  debuginfo-tests/trunk/win_cdb/realigned-frame.cpp

Index: debuginfo-tests/trunk/lit.site.cfg.py.in
===
--- debuginfo-tests/trunk/lit.site.cfg.py.in
+++ debuginfo-tests/trunk/lit.site.cfg.py.in
@@ -17,6 +17,7 @@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_arch = "@HOST_ARCH@"
+config.is_msvc = @MSVC_PYBOOL@
 
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 
Index: debuginfo-tests/trunk/lit.cfg.py
===
--- debuginfo-tests/trunk/lit.cfg.py
+++ debuginfo-tests/trunk/lit.cfg.py
@@ -38,6 +38,36 @@
 # test_exec_root: The root path where tests should be run.
 config.test_exec_root = config.debuginfo_tests_obj_root
 
+tools = [
+ToolSubst('%test_debuginfo', command=os.path.join(
+config.debuginfo_tests_src_root, 'test_debuginfo.pl')),
+]
+
+def get_required_attr(config, attr_name):
+  attr_value = getattr(config, attr_name, None)
+  if attr_value == None:
+lit_config.fatal(
+  "No attribute %r in test configuration! You may need to run "
+  "tests from your build directory or add this attribute "
+  "to lit.site.cfg " % attr_name)
+  return attr_value
+
+# If this is an MSVC environment, the tests at the root of the tree are
+# unsupported. The local win_cdb test suite, however, is supported.
+is_msvc = get_required_attr(config, "is_msvc")
+if is_msvc:
+# FIXME: We should add some llvm lit utility code to find the Windows SDK
+# and set up the environment appopriately.
+win_sdk = 'C:/Program Files (x86)/Windows Kits/10/'
+arch = 'x64'
+config.unsupported = True
+llvm_config.with_system_environment(['LIB', 'LIBPATH', 'INCLUDE'])
+# Clear _NT_SYMBOL_PATH to prevent cdb from attempting to load symbols from
+# the network.
+llvm_config.with_environment('_NT_SYMBOL_PATH', '')
+tools.append(ToolSubst('%cdb', '"%s"' % os.path.join(win_sdk, 'Debuggers',
+ arch, 'cdb.exe')))
+
 llvm_config.use_default_substitutions()
 
 # clang_src_dir is not used by these tests, but is required by
@@ -53,11 +83,6 @@
 
 tool_dirs = [config.llvm_tools_dir]
 
-tools = [
-ToolSubst('%test_debuginfo', command=os.path.join(
-config.debuginfo_tests_src_root, 'test_debuginfo.pl')),
-]
-
 llvm_config.add_tool_substitutions(tools, tool_dirs)
 
 lit.util.usePlatformSdkOnDarwin(config, lit_config)
Index: debuginfo-tests/trunk/CMakeLists.txt
===
--- debuginfo-tests/trunk/CMakeLists.txt
+++ debuginfo-tests/trunk/CMakeLists.txt
@@ -13,6 +13,9 @@
   not
   )
 
+# Indicate if this is an MSVC environment.
+pythonize_bool(MSVC)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
Index: debuginfo-tests/trunk/win_cdb/README.txt
===
--- debuginfo-tests/trunk/win_cdb/README.txt
+++ debuginfo-tests/trunk/win_cdb/README.txt
@@ -0,0 +1,6 @@
+These are debug info integration tests similar to the ones in the parent
+directory, except that these are designed to test compatibility between clang,
+lld, and cdb, the command line debugger that ships as part of the Microsoft
+Windows SDK. The debugger command language that cdb uses is very different from
+gdb and LLDB, so it's useful to be able to write some tests directly in the cdb
+command language.
Index: debuginfo-tests/trunk/win_cdb/lit.local.cfg.py
===
--- debuginfo-tests/trunk/win_cdb/lit.local.cfg.py
+++ debuginfo-tests/trunk/win_cdb/lit.local.cfg.py
@@ -0,0 +1,2 @@
+# The win_cdb tests are supported when cmake was run in an MSVC environment.
+config.unsupported = not config.is_msvc
Index: debuginfo-tests/trunk/win_cdb/hello.c
===
--- debuginfo-tests/trunk/win_cdb/hello.c
+++ debuginfo-tests/trunk/win_cdb/hello.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cl %s -o %t.exe -fuse-ld=lld -Z7
+// RUN: grep DE[B]UGGER: %s | sed -e 's/.*DE[B]UGGER: //' > %t.script
+// RUN: %cdb -cf %t.script %t.exe | FileCheck %s --check-prefixes=DEBUGGER,CHECK
+
+#include 
+int 

[PATCH] D54187: Add debuginfo-tests that use cdb on Windows

2019-05-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 201779.
rnk added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- rebase, fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54187

Files:
  debuginfo-tests/CMakeLists.txt
  debuginfo-tests/lit.cfg.py
  debuginfo-tests/lit.site.cfg.py.in
  debuginfo-tests/win_cdb/README.txt
  debuginfo-tests/win_cdb/hello.c
  debuginfo-tests/win_cdb/lit.local.cfg.py
  debuginfo-tests/win_cdb/realigned-frame.cpp

Index: debuginfo-tests/win_cdb/realigned-frame.cpp
===
--- /dev/null
+++ debuginfo-tests/win_cdb/realigned-frame.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cl %s -o %t.exe -fuse-ld=lld -Z7
+// RUN: grep DE[B]UGGER: %s | sed -e 's/.*DE[B]UGGER: //' > %t.script
+// RUN: %cdb -cf %t.script %t.exe | FileCheck %s --check-prefixes=DEBUGGER,CHECK
+
+// From https://llvm.org/pr38857, where we had issues with stack realignment.
+
+struct Foo {
+  int x = 42;
+  int __declspec(noinline) foo();
+  void __declspec(noinline) bar(int *a, int *b, double *c);
+};
+int Foo::foo() {
+  int a = 1;
+  int b = 2;
+  double __declspec(align(32)) force_alignment = 0.42;
+  bar(, , _alignment);
+  // DEBUGGER: g
+  // DEBUGGER: .frame 1
+  // DEBUGGER: dv
+  // CHECK: a = 0n1
+  // CHECK: b = 0n2
+  // CHECK: force_alignment = 0.41999{{.*}}
+  // DEBUGGER: q
+  x += (int)force_alignment;
+  return x;
+}
+void Foo::bar(int *a, int *b, double *c) {
+  __debugbreak();
+  *c += *a + *b;
+}
+int main() {
+  Foo o;
+  o.foo();
+}
Index: debuginfo-tests/win_cdb/lit.local.cfg.py
===
--- /dev/null
+++ debuginfo-tests/win_cdb/lit.local.cfg.py
@@ -0,0 +1,2 @@
+# The win_cdb tests are supported when cmake was run in an MSVC environment.
+config.unsupported = not config.is_msvc
Index: debuginfo-tests/win_cdb/hello.c
===
--- /dev/null
+++ debuginfo-tests/win_cdb/hello.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cl %s -o %t.exe -fuse-ld=lld -Z7
+// RUN: grep DE[B]UGGER: %s | sed -e 's/.*DE[B]UGGER: //' > %t.script
+// RUN: %cdb -cf %t.script %t.exe | FileCheck %s --check-prefixes=DEBUGGER,CHECK
+
+#include 
+int main() {
+  printf("hello world\n");
+  int x = 42;
+  __debugbreak();
+  // DEBUGGER: g
+  // DEBUGGER: dv
+  // CHECK: x = 0n42
+}
+// DEBUGGER: q
Index: debuginfo-tests/win_cdb/README.txt
===
--- /dev/null
+++ debuginfo-tests/win_cdb/README.txt
@@ -0,0 +1,6 @@
+These are debug info integration tests similar to the ones in the parent
+directory, except that these are designed to test compatibility between clang,
+lld, and cdb, the command line debugger that ships as part of the Microsoft
+Windows SDK. The debugger command language that cdb uses is very different from
+gdb and LLDB, so it's useful to be able to write some tests directly in the cdb
+command language.
Index: debuginfo-tests/lit.site.cfg.py.in
===
--- debuginfo-tests/lit.site.cfg.py.in
+++ debuginfo-tests/lit.site.cfg.py.in
@@ -17,6 +17,7 @@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_arch = "@HOST_ARCH@"
+config.is_msvc = @MSVC_PYBOOL@
 
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 
Index: debuginfo-tests/lit.cfg.py
===
--- debuginfo-tests/lit.cfg.py
+++ debuginfo-tests/lit.cfg.py
@@ -38,6 +38,36 @@
 # test_exec_root: The root path where tests should be run.
 config.test_exec_root = config.debuginfo_tests_obj_root
 
+tools = [
+ToolSubst('%test_debuginfo', command=os.path.join(
+config.debuginfo_tests_src_root, 'test_debuginfo.pl')),
+]
+
+def get_required_attr(config, attr_name):
+  attr_value = getattr(config, attr_name, None)
+  if attr_value == None:
+lit_config.fatal(
+  "No attribute %r in test configuration! You may need to run "
+  "tests from your build directory or add this attribute "
+  "to lit.site.cfg " % attr_name)
+  return attr_value
+
+# If this is an MSVC environment, the tests at the root of the tree are
+# unsupported. The local win_cdb test suite, however, is supported.
+is_msvc = get_required_attr(config, "is_msvc")
+if is_msvc:
+# FIXME: We should add some llvm lit utility code to find the Windows SDK
+# and set up the environment appopriately.
+win_sdk = 'C:/Program Files (x86)/Windows Kits/10/'
+arch = 'x64'
+config.unsupported = True
+llvm_config.with_system_environment(['LIB', 'LIBPATH', 'INCLUDE'])
+# Clear _NT_SYMBOL_PATH to prevent cdb from attempting to load symbols from
+# the network.
+llvm_config.with_environment('_NT_SYMBOL_PATH', '')
+tools.append(ToolSubst('%cdb', '"%s"' % os.path.join(win_sdk, 

[PATCH] D54187: Add debuginfo-tests that use cdb on Windows

2019-05-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks! I don't think this suite is going to get too far out of control. I 
think for most debug info features, checking the info itself gives enough 
confidence that things work, but there are these cases where I also want an 
integration test.

I'm picking this up again because I really want to have an integration test for 
this inline function line table bug that I'm working on: 
https://crbug.com/965670. LLVM thinks it's generating the right information, 
but the debugger doesn't interpret it the way we expect. I'll try to get these 
tests running on http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54187



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


[PATCH] D62271: [Driver] Fix -working-directory issues

2019-05-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361885: [Driver] Fix -working-directory issues (authored by 
mspencer, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62271?vs=200830=201774#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62271

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/working-directory.c

Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -616,11 +616,11 @@
 }
 
 /// Add a CC1 option to specify the debug compilation directory.
-static void addDebugCompDirArg(const ArgList , ArgStringList ) {
-  SmallString<128> cwd;
-  if (!llvm::sys::fs::current_path(cwd)) {
+static void addDebugCompDirArg(const ArgList , ArgStringList ,
+   const llvm::vfs::FileSystem ) {
+  if (llvm::ErrorOr CWD = VFS.getCurrentWorkingDirectory()) {
 CmdArgs.push_back("-fdebug-compilation-dir");
-CmdArgs.push_back(Args.MakeArgString(cwd));
+CmdArgs.push_back(Args.MakeArgString(*CWD));
   }
 }
 
@@ -885,13 +885,8 @@
   else
 OutputFilename = llvm::sys::path::filename(Output.getBaseInput());
   SmallString<128> CoverageFilename = OutputFilename;
-  if (llvm::sys::path::is_relative(CoverageFilename)) {
-SmallString<128> Pwd;
-if (!llvm::sys::fs::current_path(Pwd)) {
-  llvm::sys::path::append(Pwd, CoverageFilename);
-  CoverageFilename.swap(Pwd);
-}
-  }
+  if (llvm::sys::path::is_relative(CoverageFilename))
+(void)D.getVFS().makeAbsolute(CoverageFilename);
   llvm::sys::path::replace_extension(CoverageFilename, "gcno");
   CmdArgs.push_back(Args.MakeArgString(CoverageFilename));
 
@@ -4354,7 +4349,7 @@
 CmdArgs.push_back("-fno-autolink");
 
   // Add in -fdebug-compilation-dir if necessary.
-  addDebugCompDirArg(Args, CmdArgs);
+  addDebugCompDirArg(Args, CmdArgs, D.getVFS());
 
   addDebugPrefixMapArg(D, Args, CmdArgs);
 
@@ -6065,7 +6060,7 @@
 DebugInfoKind = (WantDebug ? codegenoptions::LimitedDebugInfo
: codegenoptions::NoDebugInfo);
 // Add the -fdebug-compilation-dir flag if needed.
-addDebugCompDirArg(Args, CmdArgs);
+addDebugCompDirArg(Args, CmdArgs, C.getDriver().getVFS());
 
 addDebugPrefixMapArg(getToolChain().getDriver(), Args, CmdArgs);
 
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -133,7 +133,7 @@
 
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
-this->VFS = llvm::vfs::getRealFileSystem();
+this->VFS = llvm::vfs::createPhysicalFileSystem().release();
 
   Name = llvm::sys::path::filename(ClangExecutable);
   Dir = llvm::sys::path::parent_path(ClangExecutable);
@@ -1005,6 +1005,11 @@
 }
   }
 
+  // Check for working directory option before accessing any files
+  if (Arg *WD = Args.getLastArg(options::OPT_working_directory))
+if (std::error_code EC = VFS->setCurrentWorkingDirectory(WD->getValue()))
+  Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
+
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 
@@ -1984,20 +1989,11 @@
   if (Value == "-")
 return true;
 
-  SmallString<64> Path(Value);
-  if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) {
-if (!llvm::sys::path::is_absolute(Path)) {
-  SmallString<64> Directory(WorkDir->getValue());
-  llvm::sys::path::append(Directory, Value);
-  Path.assign(Directory);
-}
-  }
-
-  if (getVFS().exists(Path))
+  if (getVFS().exists(Value))
 return true;
 
   if (IsCLMode()) {
-if (!llvm::sys::path::is_absolute(Twine(Path)) &&
+if (!llvm::sys::path::is_absolute(Twine(Value)) &&
 llvm::sys::Process::FindInEnvPath("LIB", Value))
   return true;
 
@@ -2023,12 +2019,12 @@
 if (getOpts().findNearest(Value, Nearest, IncludedFlagsBitmask,
   ExcludedFlagsBitmask) <= 1) {
   Diag(clang::diag::err_drv_no_such_file_with_suggestion)
-  << Path << Nearest;
+  << Value << Nearest;
   return false;
 }
   }
 
-  Diag(clang::diag::err_drv_no_such_file) << Path;
+  Diag(clang::diag::err_drv_no_such_file) << Value;
   return false;
 }
 
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -91,6 +91,8 @@
   "there is no external assembler that can be used on this platform">;
 def err_drv_unable_to_remove_file : Error<
   "unable to remove file: %0">;

r361885 - [Driver] Fix -working-directory issues

2019-05-28 Thread Michael J. Spencer via cfe-commits
Author: mspencer
Date: Tue May 28 15:21:47 2019
New Revision: 361885

URL: http://llvm.org/viewvc/llvm-project?rev=361885=rev
Log:
[Driver] Fix -working-directory issues

Currently the `-working-directory` option does not actually impact the working
directory for all of the clang driver, it only impacts how files are looked up
to make sure they exist.  This means that that clang passes the wrong paths
to -fdebug-compilation-dir and -coverage-notes-file.

This patch fixes that by changing all the places in the driver where we convert
to absolute paths to use the VFS, and then calling setCurrentWorkingDirectory on
the VFS.  This also changes the default VFS for `Driver` to use a virtualized
working directory, instead of changing the process's working directory.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/working-directory.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=361885=361884=361885=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue May 28 15:21:47 
2019
@@ -91,6 +91,8 @@ def err_no_external_assembler : Error<
   "there is no external assembler that can be used on this platform">;
 def err_drv_unable_to_remove_file : Error<
   "unable to remove file: %0">;
+def err_drv_unable_to_set_working_directory : Error <
+  "unable to set working directory: %0">;
 def err_drv_command_failure : Error<
   "unable to execute command: %0">;
 def err_drv_invalid_darwin_version : Error<

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=361885=361884=361885=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue May 28 15:21:47 2019
@@ -133,7 +133,7 @@ Driver::Driver(StringRef ClangExecutable
 
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
-this->VFS = llvm::vfs::getRealFileSystem();
+this->VFS = llvm::vfs::createPhysicalFileSystem().release();
 
   Name = llvm::sys::path::filename(ClangExecutable);
   Dir = llvm::sys::path::parent_path(ClangExecutable);
@@ -1005,6 +1005,11 @@ Compilation *Driver::BuildCompilation(Ar
 }
   }
 
+  // Check for working directory option before accessing any files
+  if (Arg *WD = Args.getLastArg(options::OPT_working_directory))
+if (std::error_code EC = VFS->setCurrentWorkingDirectory(WD->getValue()))
+  Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
+
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 
@@ -1984,20 +1989,11 @@ bool Driver::DiagnoseInputExistence(cons
   if (Value == "-")
 return true;
 
-  SmallString<64> Path(Value);
-  if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) {
-if (!llvm::sys::path::is_absolute(Path)) {
-  SmallString<64> Directory(WorkDir->getValue());
-  llvm::sys::path::append(Directory, Value);
-  Path.assign(Directory);
-}
-  }
-
-  if (getVFS().exists(Path))
+  if (getVFS().exists(Value))
 return true;
 
   if (IsCLMode()) {
-if (!llvm::sys::path::is_absolute(Twine(Path)) &&
+if (!llvm::sys::path::is_absolute(Twine(Value)) &&
 llvm::sys::Process::FindInEnvPath("LIB", Value))
   return true;
 
@@ -2023,12 +2019,12 @@ bool Driver::DiagnoseInputExistence(cons
 if (getOpts().findNearest(Value, Nearest, IncludedFlagsBitmask,
   ExcludedFlagsBitmask) <= 1) {
   Diag(clang::diag::err_drv_no_such_file_with_suggestion)
-  << Path << Nearest;
+  << Value << Nearest;
   return false;
 }
   }
 
-  Diag(clang::diag::err_drv_no_such_file) << Path;
+  Diag(clang::diag::err_drv_no_such_file) << Value;
   return false;
 }
 

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=361885=361884=361885=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue May 28 15:21:47 2019
@@ -616,11 +616,11 @@ static bool shouldUseLeafFramePointer(co
 }
 
 /// Add a CC1 option to specify the debug compilation directory.
-static void addDebugCompDirArg(const ArgList , ArgStringList ) {
-  SmallString<128> cwd;
-  if (!llvm::sys::fs::current_path(cwd)) {
+static void addDebugCompDirArg(const ArgList , ArgStringList ,
+   const llvm::vfs::FileSystem ) {

[PATCH] D62167: CodeView - add static data members to global variable debug info.

2019-05-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Is this the change we were discussing the other week semi-related to preserved 
enums? It sounded to me like the conclusion was somewhat to go ahead without 
adding all these things to the constant list and see how it goes? Is this case 
different from the enum case in some way?




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4385
+// Use the global scope for static members.
+DContext = getContextDescriptor(
+   cast(CGM.getContext().getTranslationUnitDecl()), TheCU);

rnk wrote:
> akhuang wrote:
> > akhuang wrote:
> > > dblaikie wrote:
> > > > akhuang wrote:
> > > > > @dblaikie I'm using the global scope here because if the class type 
> > > > > is used as the scope it runs into the [[ 
> > > > > https://github.com/llvm/llvm-project/blob/a2ee80b084e5c0b20364ed4379384706f5e059b1/llvm/lib/IR/DIBuilder.cpp#L630
> > > > >  | assert message ]] `Context of a global variable should not be a 
> > > > > type with identifier`. Is there a reason for the assert? 
> > > > I think it's generally how LLVM handles definitions for the most part - 
> > > > putting them at the global scope.
> > > > 
> > > > Though I'm confused by this patch - it has a source change in clang, 
> > > > but a test in LLVM. Generally there should be testing to cover where 
> > > > the source change is, I think?
> > > yep, there should be a test for this - added now. 
> > So for the global scope, it seems like [[ 
> > https://github.com/llvm-mirror/clang/blob/900624ef605b60c613342dac071228539a402ce9/lib/CodeGen/CGDebugInfo.cpp#L3274
> >  | elsewhere ]], when creating the debug info for a static data member 
> > global variable, the scope is set to be the global scope. But it would be 
> > helpful for codeview debug info if the scope remained as the class type, 
> > partially so we can use the class type information in the variable name 
> > that we emit.
> > 
> > Does it seem reasonable to remove the assert for global variable scope so 
> > that the scope can be the class here?
> I think the assertion in question is this one here in DIBuilder:
> https://github.com/llvm/llvm-project/blob/master/llvm/lib/IR/DIBuilder.cpp#L634
> 
> It looks like @manmanren added this in 2014:
> https://github.com/llvm/llvm-project/commit/bfd2b829d912ecd89f73ae32d4c683856dd677a3
> 
> @dblaikie do you know if this check is still necessary? It seems like the 
> DWARF clang generages today corresponds to C++ written this way:
> ```
> struct Foo { static const int Test2; };
> const int Foo::Test2 = 4;
> ```
> When oftentimes the source looks more like this:
> ```
> struct Foo { static const int Test2 = 4; };
> ```
> I saw a conversation between you and @probinson fixing clang irgen to avoid 
> this assert sometime back, so I figured you might be a good point of 
> reference.
My expectation is that this characterization is probably a pragmatic one of 
"it's what GCC does/we're not sure if GDB could cope with it otherwise" (we 
don't always adhere strictly to what GCC does - for instance GCC always puts 
function definitions at the CU scope, and if the function was defined in a 
namespace it puts a declaration in the namespace and references that from the 
global scoped definition - Clang goes the other way and puts the definition in 
the namespace scope (even if the function was declared there but defined from 
outside the namespace))

If that's the case (worth testing) then arguably the frontend should emit the 
more accurate metadata and the DWARF backend could fudge this - or like some of 
the other stuff we do we could emit different metadata in the frontend 
depending on the DWARF v CodeView split.


On further experimentation, I'm somewhat confused what this change is about. In 
ToT, this code:

  struct foo {
static const int bar = 3;
  };
  int f() {
return foo::bar;
  }

Becomes DWARF that has a DICompositeType with elements pointing to a 
DIDerivedType:DW_TAG_member with the extraData of i32 3.

And that becomes this DWARF:

  TAG_structure_type
AT_name "foo"
TAG_member
  AT_name "foo"
  declaration true
  const_value 3

which seems accurate to me - this isn't a variable definition, it's a 
declaration with a value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62167



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


[PATCH] D62551: [analyzer][Dominator] Add post dominator tree builder for the CFG + a debug checker

2019-05-28 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar added inline comments.



Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:111
+  assert(
+  (IDom && !IDom->getBlock() && *I == &(*I)->getParent()->getExit() &&
+   IsPostDom) ||

kuhar wrote:
> Szelethus wrote:
> > kuhar wrote:
> > > Assertions with multiple conditions conjoined are difficult to debug -- 
> > > perhaps it'd be better to split them and assign to separate booleans for 
> > > each condition, with descriptive names? This code can be hidden behind an 
> > > ifdef for debug. 
> > Do you like this better? I prefer running static analysis on large 
> > codebases with a Release+Asserts build, and I fear that this check will be 
> > lost if I use `#ifdef DEBUG`.
> I think it's much more readable now, thanks! Release+Asserts defines NDEBUG 
> and the assertion will work if you put it into an ifdef.
*does not define NDEBUG


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

https://reviews.llvm.org/D62551



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


[PATCH] D62551: [analyzer][Dominator] Add post dominator tree builder for the CFG + a debug checker

2019-05-28 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar added inline comments.



Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:111
+  assert(
+  (IDom && !IDom->getBlock() && *I == &(*I)->getParent()->getExit() &&
+   IsPostDom) ||

Szelethus wrote:
> kuhar wrote:
> > Assertions with multiple conditions conjoined are difficult to debug -- 
> > perhaps it'd be better to split them and assign to separate booleans for 
> > each condition, with descriptive names? This code can be hidden behind an 
> > ifdef for debug. 
> Do you like this better? I prefer running static analysis on large codebases 
> with a Release+Asserts build, and I fear that this check will be lost if I 
> use `#ifdef DEBUG`.
I think it's much more readable now, thanks! Release+Asserts defines NDEBUG and 
the assertion will work if you put it into an ifdef.


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

https://reviews.llvm.org/D62551



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


[PATCH] D62551: [analyzer][Dominator] Add post dominator tree builder for the CFG + a debug checker

2019-05-28 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 201769.
Szelethus edited the summary of this revision.
Szelethus added a comment.

Fixes according to @kuhar's comments, thanks!


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

https://reviews.llvm.org/D62551

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/Analysis/Dominators.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  clang/test/Analysis/domtest.c
  clang/test/Analysis/domtest.cpp

Index: clang/test/Analysis/domtest.cpp
===
--- clang/test/Analysis/domtest.cpp
+++ clang/test/Analysis/domtest.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=debug.DumpCFG \
 // RUN:   -analyzer-checker=debug.DumpDominators \
+// RUN:   -analyzer-checker=debug.DumpPostDominators \
 // RUN:   2>&1 | FileCheck %s
 
 namespace pr42041_unreachable_cfg_successor {
@@ -44,3 +45,8 @@
 // CHECK-NEXT: (1,3)
 // CHECK-NEXT: (2,1)
 // CHECK-NEXT: (3,3)
+// CHECK-NEXT: Immediate post dominance tree (Node#,IDom#):
+// CHECK-NEXT: (0,0)
+// CHECK-NEXT: (1,2)
+// CHECK-NEXT: (2,0)
+// CHECK-NEXT: (3,1)
Index: clang/test/Analysis/domtest.c
===
--- clang/test/Analysis/domtest.c
+++ clang/test/Analysis/domtest.c
@@ -1,6 +1,8 @@
-// RUN: rm -f %t
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpDominators %s > %t 2>&1
-// RUN: FileCheck --input-file=%t %s
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=debug.DumpCFG \
+// RUN:   -analyzer-checker=debug.DumpDominators \
+// RUN:   -analyzer-checker=debug.DumpPostDominators \
+// RUN:   2>&1 | FileCheck %s
 
 // Test the DominatorsTree implementation with various control flows
 int test1()
@@ -24,17 +26,130 @@
   return 0;
 }
 
-// CHECK: Immediate dominance tree (Node#,IDom#):
-// CHECK: (0,1)
-// CHECK: (1,7)
-// CHECK: (2,3)
-// CHECK: (3,6)
-// CHECK: (4,6)
-// CHECK: (5,6)
-// CHECK: (6,7)
-// CHECK: (7,8)
-// CHECK: (8,9)
-// CHECK: (9,9)
+// CHECK:  int test1()
+// CHECK-NEXT:  [B9 (ENTRY)]
+// CHECK-NEXT:Succs (1): B8
+//
+// CHECK:   [B1]
+// CHECK-NEXT:1: x
+// CHECK-NEXT:2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: y
+// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:5: [B1.2] + [B1.4]
+// CHECK-NEXT:6: z
+// CHECK-NEXT:7: [B1.6] = [B1.5]
+// CHECK-NEXT:8: 3
+// CHECK-NEXT:9: z
+// CHECK-NEXT:   10: [B1.9] = [B1.8]
+// CHECK-NEXT:   11: 0
+// CHECK-NEXT:   12: return [B1.11];
+// CHECK-NEXT:Preds (1): B7
+// CHECK-NEXT:Succs (1): B0
+//
+// CHECK:   [B2]
+// CHECK-NEXT:Preds (1): B3
+// CHECK-NEXT:Succs (1): B7
+//
+// CHECK:   [B3]
+// CHECK-NEXT:1: x
+// CHECK-NEXT:2: [B3.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: 1
+// CHECK-NEXT:4: [B3.2] - [B3.3]
+// CHECK-NEXT:5: x
+// CHECK-NEXT:6: [B3.5] = [B3.4]
+// CHECK-NEXT:7: x
+// CHECK-NEXT:8: [B3.7] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:9: 1
+// CHECK-NEXT:   10: [B3.8] - [B3.9]
+// CHECK-NEXT:   11: x
+// CHECK-NEXT:   12: [B3.11] = [B3.10]
+// CHECK-NEXT:Preds (2): B4 B5
+// CHECK-NEXT:Succs (1): B2
+//
+// CHECK:   [B4]
+// CHECK-NEXT:1: x
+// CHECK-NEXT:2: [B4.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: y
+// CHECK-NEXT:4: [B4.3] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:5: [B4.2] - [B4.4]
+// CHECK-NEXT:6: z
+// CHECK-NEXT:7: [B4.6] = [B4.5]
+// CHECK-NEXT:Preds (1): B6
+// CHECK-NEXT:Succs (1): B3
+//
+// CHECK:   [B5]
+// CHECK-NEXT:1: x
+// CHECK-NEXT:2: [B5.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: y
+// CHECK-NEXT:4: [B5.3] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:5: [B5.2] / [B5.4]
+// CHECK-NEXT:6: x
+// CHECK-NEXT:7: [B5.6] = [B5.5]
+// CHECK-NEXT:8: y
+// CHECK-NEXT:9: [B5.8] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   10: 1
+// CHECK-NEXT:   11: [B5.9] - [B5.10]
+// CHECK-NEXT:   12: y
+// CHECK-NEXT:   13: [B5.12] = [B5.11]
+// CHECK-NEXT:Preds (1): B6
+// CHECK-NEXT:Succs (1): B3
+//
+// CHECK:   [B6]
+// CHECK-NEXT:1: y
+// CHECK-NEXT:2: [B6.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: x
+// CHECK-NEXT:4: [B6.3] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:5: [B6.2] < [B6.4]
+// CHECK-NEXT:T: if [B6.5]
+// CHECK-NEXT:Preds (1): B7
+// CHECK-NEXT:Succs (2): B5 B4
+//
+// CHECK:   [B7]
+// CHECK-NEXT:1: y
+// CHECK-NEXT:2: [B7.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: 0
+// CHECK-NEXT:4: [B7.2] > [B7.3]
+// CHECK-NEXT:T: while [B7.4]
+// CHECK-NEXT:Preds (2): B2 B8
+// CHECK-NEXT:Succs (2): B6 B1
+//
+// CHECK:

[PATCH] D62551: [analyzer][Dominator] Add post dominator tree builder for the CFG + a debug checker

2019-05-28 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked 5 inline comments as done.
Szelethus added inline comments.



Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:111
+  assert(
+  (IDom && !IDom->getBlock() && *I == &(*I)->getParent()->getExit() &&
+   IsPostDom) ||

kuhar wrote:
> Assertions with multiple conditions conjoined are difficult to debug -- 
> perhaps it'd be better to split them and assign to separate booleans for each 
> condition, with descriptive names? This code can be hidden behind an ifdef 
> for debug. 
Do you like this better? I prefer running static analysis on large codebases 
with a Release+Asserts build, and I fear that this check will be lost if I use 
`#ifdef DEBUG`.


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

https://reviews.llvm.org/D62551



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


[clang-tools-extra] r361883 - [clangd] Add SourceManager accessor to ParsedAST. NFC

2019-05-28 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue May 28 14:52:34 2019
New Revision: 361883

URL: http://llvm.org/viewvc/llvm-project?rev=361883=rev
Log:
[clangd] Add SourceManager accessor to ParsedAST. NFC

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/refactor/Rename.cpp
clang-tools-extra/trunk/clangd/refactor/Tweak.cpp
clang-tools-extra/trunk/clangd/refactor/tweaks/RawStringLiteral.cpp
clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp
clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp
clang-tools-extra/trunk/clangd/unittests/SelectionTests.cpp
clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.h?rev=361883=361882=361883=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.h Tue May 28 14:52:34 2019
@@ -95,6 +95,13 @@ public:
   std::shared_ptr getPreprocessorPtr();
   const Preprocessor () const;
 
+  SourceManager () {
+return getASTContext().getSourceManager();
+  }
+  const SourceManager () const {
+return getASTContext().getSourceManager();
+  }
+
   /// This function returns top-level decls present in the main file of the 
AST.
   /// The result does not include the decls that come from the preamble.
   /// (These should be const, but RecursiveASTVisitor requires Decl*).

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=361883=361882=361883=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Tue May 28 14:52:34 2019
@@ -286,7 +286,7 @@ llvm::Optional makeLocation(AS
 
 std::vector locateSymbolAt(ParsedAST , Position Pos,
   const SymbolIndex *Index) {
-  const auto  = AST.getASTContext().getSourceManager();
+  const auto  = AST.getSourceManager();
   auto MainFilePath =
   getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
   if (!MainFilePath) {
@@ -461,7 +461,7 @@ findRefs(const std::vector
 
 std::vector findDocumentHighlights(ParsedAST ,
   Position Pos) {
-  const SourceManager  = AST.getASTContext().getSourceManager();
+  const SourceManager  = AST.getSourceManager();
   auto Symbols = getSymbolAtPosition(
   AST, getBeginningOfIdentifier(AST, Pos, SM.getMainFileID()));
   auto References = findRefs(Symbols.Decls, AST);
@@ -719,7 +719,7 @@ static HoverInfo getHoverContents(QualTy
 /// Generate a \p Hover object given the macro \p MacroDecl.
 static HoverInfo getHoverContents(MacroDecl Decl, ParsedAST ) {
   HoverInfo HI;
-  SourceManager  = AST.getASTContext().getSourceManager();
+  SourceManager  = AST.getSourceManager();
   HI.Name = Decl.Name;
   HI.Kind = indexSymbolKindToSymbolKind(
   index::getSymbolInfoForMacro(*Decl.Info).Kind);
@@ -864,9 +864,8 @@ bool hasDeducedType(ParsedAST , Sour
 llvm::Optional getHover(ParsedAST , Position Pos,
format::FormatStyle Style) {
   llvm::Optional HI;
-  const SourceManager  = AST.getASTContext().getSourceManager();
-  SourceLocation SourceLocationBeg =
-  getBeginningOfIdentifier(AST, Pos, SourceMgr.getMainFileID());
+  SourceLocation SourceLocationBeg = getBeginningOfIdentifier(
+  AST, Pos, AST.getSourceManager().getMainFileID());
   // Identified symbols at a specific position.
   auto Symbols = getSymbolAtPosition(AST, SourceLocationBeg);
 
@@ -900,7 +899,7 @@ std::vector findReferences(Par
   if (!Limit)
 Limit = std::numeric_limits::max();
   std::vector Results;
-  const SourceManager  = AST.getASTContext().getSourceManager();
+  const SourceManager  = AST.getSourceManager();
   auto MainFilePath =
   getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
   if (!MainFilePath) {
@@ -949,7 +948,7 @@ std::vector findReferences(Par
 }
 
 std::vector getSymbolInfo(ParsedAST , Position Pos) {
-  const SourceManager  = AST.getASTContext().getSourceManager();
+  const SourceManager  = AST.getSourceManager();
 
   auto Loc = getBeginningOfIdentifier(AST, Pos, SM.getMainFileID());
   auto Symbols = getSymbolAtPosition(AST, Loc);
@@ -1084,10 +1083,8 @@ getTypeAncestors(const CXXRecordDecl 
 }
 
 const CXXRecordDecl *findRecordTypeAt(ParsedAST , Position Pos) {
-  ASTContext  = AST.getASTContext();
-  const SourceManager  = ASTCtx.getSourceManager();
-  SourceLocation SourceLocationBeg =
-  getBeginningOfIdentifier(AST, Pos, SourceMgr.getMainFileID());
+  SourceLocation SourceLocationBeg = getBeginningOfIdentifier(
+  AST, Pos, 

[PATCH] D62538: [clangd] Add hidden tweaks to dump AST/selection.

2019-05-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 201765.
sammccall added a comment.

Add DumpRecordLayout. Fix a small SelectionTree bug uncovered by these tweaks.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62538

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/Selection.cpp
  clangd/refactor/Tweak.h
  clangd/refactor/tweaks/CMakeLists.txt
  clangd/refactor/tweaks/DumpAST.cpp
  clangd/refactor/tweaks/RawStringLiteral.cpp
  clangd/refactor/tweaks/SwapIfBranches.cpp
  clangd/tool/ClangdMain.cpp
  clangd/unittests/SelectionTests.cpp
  clangd/unittests/TweakTests.cpp

Index: clangd/unittests/TweakTests.cpp
===
--- clangd/unittests/TweakTests.cpp
+++ clangd/unittests/TweakTests.cpp
@@ -16,12 +16,12 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock-matchers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
 
 using llvm::Failed;
-using llvm::HasValue;
 using llvm::Succeeded;
 
 namespace clang {
@@ -76,7 +76,8 @@
 void checkNotAvailable(StringRef ID, llvm::StringRef Input) {
   return checkAvailable(ID, Input, /*Available=*/false);
 }
-llvm::Expected apply(StringRef ID, llvm::StringRef Input) {
+
+llvm::Expected apply(StringRef ID, llvm::StringRef Input) {
   Annotations Code(Input);
   Range SelectionRng;
   if (Code.points().size() != 0) {
@@ -98,15 +99,30 @@
   auto T = prepareTweak(ID, S);
   if (!T)
 return T.takeError();
-  auto Replacements = (*T)->apply(S);
-  if (!Replacements)
-return Replacements.takeError();
-  return applyAllReplacements(Code.code(), *Replacements);
+  return (*T)->apply(S);
+}
+
+llvm::Expected applyEdit(StringRef ID, llvm::StringRef Input) {
+  auto Effect = apply(ID, Input);
+  if (!Effect)
+return Effect.takeError();
+  if (!Effect->ApplyEdit)
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "No replacements");
+  Annotations Code(Input);
+  return applyAllReplacements(Code.code(), *Effect->ApplyEdit);
+}
+
+std::string getMessage(StringRef ID, llvm::StringRef Input) {
+  auto Effect = apply(ID, Input);
+  if (!Effect)
+return "error: " + llvm::toString(Effect.takeError());
+  return Effect->ShowMessage.getValueOr("no message produced!");
 }
 
 void checkTransform(llvm::StringRef ID, llvm::StringRef Input,
 std::string Output) {
-  auto Result = apply(ID, Input);
+  auto Result = applyEdit(ID, Input);
   ASSERT_TRUE(bool(Result)) << llvm::toString(Result.takeError()) << Input;
   EXPECT_EQ(Output, std::string(*Result)) << Input;
 }
@@ -217,6 +233,49 @@
   checkTransform(ID, Input, Output);
 }
 
+TEST(TweakTest, DumpAST) {
+  llvm::StringLiteral ID = "DumpAST";
+
+  checkAvailable(ID, "^int f^oo() { re^turn 2 ^+ 2; }");
+  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));
+}
+
+TEST(TweakTest, ShowSelectionTree) {
+  llvm::StringLiteral ID = "ShowSelectionTree";
+
+  checkAvailable(ID, "^int f^oo() { re^turn 2 ^+ 2; }");
+  checkNotAvailable(ID, "/*c^omment*/ int foo() return 2 ^ + 2; }");
+
+  const char *Input = "int fcall(int); int x = fca[[ll(2 +]]2);";
+  const char *Output = R"(TranslationUnitDecl 
+  VarDecl int x = fcall(2 + 2)
+   .CallExpr fcall(2 + 2)
+  ImplicitCastExpr fcall
+   .DeclRefExpr fcall
+ .BinaryOperator 2 + 2
+   *IntegerLiteral 2
+)";
+  EXPECT_EQ(Output, getMessage(ID, Input));
+}
+
+TEST(TweakTest, DumpRecordLayout) {
+  llvm::StringLiteral ID = "DumpRecordLayout";
+  checkAvailable(ID, "^s^truct ^X ^{ int x; ^};");
+  checkNotAvailable(ID, "struct X { int ^a; };");
+  checkNotAvailable(ID, "struct ^X;");
+  checkNotAvailable(ID, "template  struct ^X { T t; };");
+  checkNotAvailable(ID, "enum ^X {};");
+
+  const char *Input = "struct ^X { int x; int y; }";
+  EXPECT_THAT(getMessage(ID, Input), ::testing::HasSubstr("0 |   int x"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/unittests/SelectionTests.cpp
===
--- clangd/unittests/SelectionTests.cpp
+++ clangd/unittests/SelectionTests.cpp
@@ -216,6 +216,16 @@
   }
 }
 
+// Regression test: this used to match the injected X, not the outer X.
+TEST(SelectionTest, InjectedClassName) {
+  const char* Code = "struct ^X { int x; };";
+  auto AST = TestTU::withCode(Annotations(Code).code()).build();
+  auto T = makeSelectionTree(Code, AST);
+  ASSERT_EQ("CXXRecordDecl", nodeKind(T.commonAncestor())) << T;
+  auto *D = 

[PATCH] D62483: [CUDA][HIP] Emit dependent libs for host only

2019-05-28 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361880: [CUDA][HIP] Emit dependent libs for host only 
(authored by yaxunl, committed by ).
Herald added a project: clang.

Repository:
  rC Clang

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

https://reviews.llvm.org/D62483

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCUDA/dependent-libs.cu


Index: test/CodeGenCUDA/dependent-libs.cu
===
--- test/CodeGenCUDA/dependent-libs.cu
+++ test/CodeGenCUDA/dependent-libs.cu
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck 
--check-prefix=DEV %s
+// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s
+
+// DEV-NOT: llvm.dependent-libraries
+// HOST: llvm.dependent-libraries
+#pragma comment(lib, "libabc")
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -457,7 +457,12 @@
   // that ELF linkers tend to handle libraries in a more complicated fashion
   // than on other platforms. This forces us to defer handling the dependent
   // libs to the linker.
-  if (!ELFDependentLibraries.empty()) {
+  //
+  // CUDA/HIP device and host libraries are different. Currently there is no
+  // way to differentiate dependent libraries for host or device. Existing
+  // usage of #pragma comment(lib, *) is intended for host libraries on
+  // Windows. Therefore emit llvm.dependent-libraries only for host.
+  if (!ELFDependentLibraries.empty() && !Context.getLangOpts().CUDAIsDevice) {
 auto *NMD = 
getModule().getOrInsertNamedMetadata("llvm.dependent-libraries");
 for (auto *MD : ELFDependentLibraries)
   NMD->addOperand(MD);


Index: test/CodeGenCUDA/dependent-libs.cu
===
--- test/CodeGenCUDA/dependent-libs.cu
+++ test/CodeGenCUDA/dependent-libs.cu
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck --check-prefix=DEV %s
+// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s
+
+// DEV-NOT: llvm.dependent-libraries
+// HOST: llvm.dependent-libraries
+#pragma comment(lib, "libabc")
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -457,7 +457,12 @@
   // that ELF linkers tend to handle libraries in a more complicated fashion
   // than on other platforms. This forces us to defer handling the dependent
   // libs to the linker.
-  if (!ELFDependentLibraries.empty()) {
+  //
+  // CUDA/HIP device and host libraries are different. Currently there is no
+  // way to differentiate dependent libraries for host or device. Existing
+  // usage of #pragma comment(lib, *) is intended for host libraries on
+  // Windows. Therefore emit llvm.dependent-libraries only for host.
+  if (!ELFDependentLibraries.empty() && !Context.getLangOpts().CUDAIsDevice) {
 auto *NMD = getModule().getOrInsertNamedMetadata("llvm.dependent-libraries");
 for (auto *MD : ELFDependentLibraries)
   NMD->addOperand(MD);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62019: [clang] Handle lrint/llrint builtins

2019-05-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361878: [clang] Handle lrint/llrint builtins (authored by 
azanella, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62019?vs=200291=201763#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62019

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtins.c
  test/CodeGen/math-builtins.c
  test/CodeGen/math-libcalls.c

Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -353,9 +353,9 @@
 
   __builtin_llrint(f); __builtin_llrintf(f);__builtin_llrintl(f);
 
-// NO__ERRNO: declare i64 @llrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintl(x86_fp80) [[NOT_READNONE]]
@@ -416,9 +416,9 @@
 
   __builtin_lrint(f);  __builtin_lrintf(f); __builtin_lrintl(f);
 
-// NO__ERRNO: declare i64 @lrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintl(x86_fp80) [[NOT_READNONE]]
Index: test/CodeGen/math-libcalls.c
===
--- test/CodeGen/math-libcalls.c
+++ test/CodeGen/math-libcalls.c
@@ -308,9 +308,9 @@
 
   llrint(f); llrintf(f);llrintl(f);
 
-// NO__ERRNO: declare i64 @llrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintl(x86_fp80) [[NOT_READNONE]]
@@ -371,9 +371,9 @@
 
   lrint(f);  lrintf(f); lrintl(f);
 
-// NO__ERRNO: declare i64 @lrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintl(x86_fp80) [[NOT_READNONE]]
Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -390,6 +390,15 @@
 
   resli = __builtin_lroundl (LD);
   // CHECK: call i64 @llvm.lround.i64.f80
+
+  resli = __builtin_lrintf (F);
+  // CHECK: call i64 @llvm.lrint.i64.f32
+
+  resli = __builtin_lrint (D);
+  // CHECK: call i64 @llvm.lrint.i64.f64
+
+  resli = __builtin_lrintl (LD);
+  // CHECK: call i64 @llvm.lrint.i64.f80
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1741,6 +1741,22 @@
 case Builtin::BI__builtin_llroundl:
   return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::llround));
 
+case Builtin::BIlrint:
+case Builtin::BIlrintf:
+case Builtin::BIlrintl:
+case Builtin::BI__builtin_lrint:
+case Builtin::BI__builtin_lrintf:
+case Builtin::BI__builtin_lrintl:
+  return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::lrint));
+
+case Builtin::BIllrint:
+case Builtin::BIllrintf:
+case Builtin::BIllrintl:
+case Builtin::BI__builtin_llrint:
+case Builtin::BI__builtin_llrintf:
+case Builtin::BI__builtin_llrintl:
+  return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::llrint));
+
 

[PATCH] D62551: [analyzer][Dominator] Add post dominator tree builder for the CFG + a debug checker

2019-05-28 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar added inline comments.



Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:39
 
 /// Concrete subclass of DominatorTreeBase for Clang
 /// This class implements the dominators tree functionality given a Clang CFG.

Seems outdated?



Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:47
 public:
-  llvm::DomTreeBase *DT;
+  using DomTreeBase = llvm::DominatorTreeBase;
 

nit: I think this can name can be somewhat confusing as it's not a base class 
of CFGDomTree.



Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:49
 
-  DominatorTree() {
-DT = new llvm::DomTreeBase();
+  DomTreeBase *DT;
+

Why not  have it as a value member? Or a unique_ptr, if pointer semantics are 
really desired.



Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:111
+  assert(
+  (IDom && !IDom->getBlock() && *I == &(*I)->getParent()->getExit() &&
+   IsPostDom) ||

Assertions with multiple conditions conjoined are difficult to debug -- perhaps 
it'd be better to split them and assign to separate booleans for each 
condition, with descriptive names? This code can be hidden behind an ifdef for 
debug. 



Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:174
 
+using DominatorTree = CFGDominatorTree;
+using PostDominatorTree = CFGDominatorTree;

nit: How about having the parent class template called CFGDominatorTreeImpl and 
these two as CFGDomTree and CFGPostdomTree?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62551



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


r361880 - [CUDA][HIP] Emit dependent libs for host only

2019-05-28 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue May 28 14:18:59 2019
New Revision: 361880

URL: http://llvm.org/viewvc/llvm-project?rev=361880=rev
Log:
[CUDA][HIP] Emit dependent libs for host only

Recently D60274 was introduced to allow lld to handle dependent libs. However 
current
usage of dependent libs (e.g. pragma comment(lib, *) in windows header files) 
are intended
for host only. Emitting the metadata in device IR causes link error in device 
path.

Until there is a way to different it dependent libs for device or host, 
metadata for dependent
libs should be emitted for host only. This patch enforces that.

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

Added:
cfe/trunk/test/CodeGenCUDA/dependent-libs.cu
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=361880=361879=361880=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue May 28 14:18:59 2019
@@ -457,7 +457,12 @@ void CodeGenModule::Release() {
   // that ELF linkers tend to handle libraries in a more complicated fashion
   // than on other platforms. This forces us to defer handling the dependent
   // libs to the linker.
-  if (!ELFDependentLibraries.empty()) {
+  //
+  // CUDA/HIP device and host libraries are different. Currently there is no
+  // way to differentiate dependent libraries for host or device. Existing
+  // usage of #pragma comment(lib, *) is intended for host libraries on
+  // Windows. Therefore emit llvm.dependent-libraries only for host.
+  if (!ELFDependentLibraries.empty() && !Context.getLangOpts().CUDAIsDevice) {
 auto *NMD = 
getModule().getOrInsertNamedMetadata("llvm.dependent-libraries");
 for (auto *MD : ELFDependentLibraries)
   NMD->addOperand(MD);

Added: cfe/trunk/test/CodeGenCUDA/dependent-libs.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/dependent-libs.cu?rev=361880=auto
==
--- cfe/trunk/test/CodeGenCUDA/dependent-libs.cu (added)
+++ cfe/trunk/test/CodeGenCUDA/dependent-libs.cu Tue May 28 14:18:59 2019
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck 
--check-prefix=DEV %s
+// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s
+
+// DEV-NOT: llvm.dependent-libraries
+// HOST: llvm.dependent-libraries
+#pragma comment(lib, "libabc")


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


r361878 - [clang] Handle lrint/llrint builtins

2019-05-28 Thread Adhemerval Zanella via cfe-commits
Author: azanella
Date: Tue May 28 14:16:04 2019
New Revision: 361878

URL: http://llvm.org/viewvc/llvm-project?rev=361878=rev
Log:
[clang] Handle lrint/llrint builtins

As for other floating-point rounding builtins that can be optimized
when build with -fno-math-errno, this patch adds support for lrint
and llrint.  It currently only optimize for AArch64 backend.

Reviewed By: craig.topper

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c
cfe/trunk/test/CodeGen/math-builtins.c
cfe/trunk/test/CodeGen/math-libcalls.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=361878=361877=361878=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May 28 14:16:04 2019
@@ -1741,6 +1741,22 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 case Builtin::BI__builtin_llroundl:
   return RValue::get(emitFPToIntRoundBuiltin(*this, E, 
Intrinsic::llround));
 
+case Builtin::BIlrint:
+case Builtin::BIlrintf:
+case Builtin::BIlrintl:
+case Builtin::BI__builtin_lrint:
+case Builtin::BI__builtin_lrintf:
+case Builtin::BI__builtin_lrintl:
+  return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::lrint));
+
+case Builtin::BIllrint:
+case Builtin::BIllrintf:
+case Builtin::BIllrintl:
+case Builtin::BI__builtin_llrint:
+case Builtin::BI__builtin_llrintf:
+case Builtin::BI__builtin_llrintl:
+  return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::llrint));
+
 default:
   break;
 }

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=361878=361877=361878=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Tue May 28 14:16:04 2019
@@ -390,6 +390,15 @@ void test_float_builtin_ops(float F, dou
 
   resli = __builtin_lroundl (LD);
   // CHECK: call i64 @llvm.lround.i64.f80
+
+  resli = __builtin_lrintf (F);
+  // CHECK: call i64 @llvm.lrint.i64.f32
+
+  resli = __builtin_lrint (D);
+  // CHECK: call i64 @llvm.lrint.i64.f64
+
+  resli = __builtin_lrintl (LD);
+  // CHECK: call i64 @llvm.lrint.i64.f80
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.

Modified: cfe/trunk/test/CodeGen/math-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/math-builtins.c?rev=361878=361877=361878=diff
==
--- cfe/trunk/test/CodeGen/math-builtins.c (original)
+++ cfe/trunk/test/CodeGen/math-builtins.c Tue May 28 14:16:04 2019
@@ -353,9 +353,9 @@ void foo(double *d, float f, float *fp,
 
   __builtin_llrint(f); __builtin_llrintf(f);__builtin_llrintl(f);
 
-// NO__ERRNO: declare i64 @llrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintl(x86_fp80) [[NOT_READNONE]]
@@ -416,9 +416,9 @@ void foo(double *d, float f, float *fp,
 
   __builtin_lrint(f);  __builtin_lrintf(f); __builtin_lrintl(f);
 
-// NO__ERRNO: declare i64 @lrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintl(x86_fp80) [[NOT_READNONE]]

Modified: cfe/trunk/test/CodeGen/math-libcalls.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/math-libcalls.c?rev=361878=361877=361878=diff
==
--- cfe/trunk/test/CodeGen/math-libcalls.c (original)
+++ cfe/trunk/test/CodeGen/math-libcalls.c Tue May 28 14:16:04 2019
@@ -308,9 +308,9 @@ void foo(double *d, float f, float *fp,
 
   llrint(f); llrintf(f);llrintl(f);
 
-// NO__ERRNO: declare i64 @llrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 

[PATCH] D61974: [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

LGTM.  David should sign off, too, though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61974



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


[PATCH] D62551: [analyzer][Dominator] Add post dominator tree builder for the CFG + a debug checker

2019-05-28 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, kuhar, xazax.hun, rnkovacs, dcoughlin, 
baloghadamsoftware, Charusso.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, whisperity.
Szelethus added a parent revision: D62507: [Dominators] PR42041: Skip 
nullpointer successors.

Transform `clang::DominatorTree` to be able to also calculate post dominators.

- Tidy up the documentation
- Rename `clang::DominatorTree` to `clang::CFGDominatorTree`
- Make it a template class, similarly to `llvm::DominatorTreeBase`
- Add a lot of asserts to the `dump()` function
- Create a new checker to test the functionality


Repository:
  rC Clang

https://reviews.llvm.org/D62551

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/Analysis/Dominators.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  clang/test/Analysis/domtest.c
  clang/test/Analysis/domtest.cpp

Index: clang/test/Analysis/domtest.cpp
===
--- clang/test/Analysis/domtest.cpp
+++ clang/test/Analysis/domtest.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=debug.DumpCFG \
 // RUN:   -analyzer-checker=debug.DumpDominators \
+// RUN:   -analyzer-checker=debug.DumpPostDominators \
 // RUN:   2>&1 | FileCheck %s
 
 namespace pr42041_unreachable_cfg_successor {
@@ -44,3 +45,8 @@
 // CHECK-NEXT: (1,3)
 // CHECK-NEXT: (2,1)
 // CHECK-NEXT: (3,3)
+// CHECK-NEXT: Immediate post dominance tree (Node#,IDom#):
+// CHECK-NEXT: (0,0)
+// CHECK-NEXT: (1,2)
+// CHECK-NEXT: (2,0)
+// CHECK-NEXT: (3,1)
Index: clang/test/Analysis/domtest.c
===
--- clang/test/Analysis/domtest.c
+++ clang/test/Analysis/domtest.c
@@ -1,6 +1,8 @@
-// RUN: rm -f %t
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpDominators %s > %t 2>&1
-// RUN: FileCheck --input-file=%t %s
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=debug.DumpCFG \
+// RUN:   -analyzer-checker=debug.DumpDominators \
+// RUN:   -analyzer-checker=debug.DumpPostDominators \
+// RUN:   2>&1 | FileCheck %s
 
 // Test the DominatorsTree implementation with various control flows
 int test1()
@@ -24,17 +26,130 @@
   return 0;
 }
 
-// CHECK: Immediate dominance tree (Node#,IDom#):
-// CHECK: (0,1)
-// CHECK: (1,7)
-// CHECK: (2,3)
-// CHECK: (3,6)
-// CHECK: (4,6)
-// CHECK: (5,6)
-// CHECK: (6,7)
-// CHECK: (7,8)
-// CHECK: (8,9)
-// CHECK: (9,9)
+// CHECK:  int test1()
+// CHECK-NEXT:  [B9 (ENTRY)]
+// CHECK-NEXT:Succs (1): B8
+//
+// CHECK:   [B1]
+// CHECK-NEXT:1: x
+// CHECK-NEXT:2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: y
+// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:5: [B1.2] + [B1.4]
+// CHECK-NEXT:6: z
+// CHECK-NEXT:7: [B1.6] = [B1.5]
+// CHECK-NEXT:8: 3
+// CHECK-NEXT:9: z
+// CHECK-NEXT:   10: [B1.9] = [B1.8]
+// CHECK-NEXT:   11: 0
+// CHECK-NEXT:   12: return [B1.11];
+// CHECK-NEXT:Preds (1): B7
+// CHECK-NEXT:Succs (1): B0
+//
+// CHECK:   [B2]
+// CHECK-NEXT:Preds (1): B3
+// CHECK-NEXT:Succs (1): B7
+//
+// CHECK:   [B3]
+// CHECK-NEXT:1: x
+// CHECK-NEXT:2: [B3.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: 1
+// CHECK-NEXT:4: [B3.2] - [B3.3]
+// CHECK-NEXT:5: x
+// CHECK-NEXT:6: [B3.5] = [B3.4]
+// CHECK-NEXT:7: x
+// CHECK-NEXT:8: [B3.7] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:9: 1
+// CHECK-NEXT:   10: [B3.8] - [B3.9]
+// CHECK-NEXT:   11: x
+// CHECK-NEXT:   12: [B3.11] = [B3.10]
+// CHECK-NEXT:Preds (2): B4 B5
+// CHECK-NEXT:Succs (1): B2
+//
+// CHECK:   [B4]
+// CHECK-NEXT:1: x
+// CHECK-NEXT:2: [B4.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: y
+// CHECK-NEXT:4: [B4.3] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:5: [B4.2] - [B4.4]
+// CHECK-NEXT:6: z
+// CHECK-NEXT:7: [B4.6] = [B4.5]
+// CHECK-NEXT:Preds (1): B6
+// CHECK-NEXT:Succs (1): B3
+//
+// CHECK:   [B5]
+// CHECK-NEXT:1: x
+// CHECK-NEXT:2: [B5.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: y
+// CHECK-NEXT:4: [B5.3] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:5: [B5.2] / [B5.4]
+// CHECK-NEXT:6: x
+// CHECK-NEXT:7: [B5.6] = [B5.5]
+// CHECK-NEXT:8: y
+// CHECK-NEXT:9: [B5.8] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   10: 1
+// CHECK-NEXT:   11: [B5.9] - [B5.10]
+// CHECK-NEXT:   12: y
+// CHECK-NEXT:   13: [B5.12] = [B5.11]
+// CHECK-NEXT:Preds (1): B6
+// CHECK-NEXT:Succs (1): B3
+//
+// CHECK:   [B6]
+// CHECK-NEXT:1: y
+// CHECK-NEXT:2: [B6.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:3: x
+// 

[PATCH] D61974: [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 201760.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Remove flag `EncodePointerToObjCTypedef`, which is no longer needed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61974

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  test/CodeGenObjC/encode-test-6.m
  test/CodeGenObjC/encode-test.m
  test/CodeGenObjCXX/encode.mm

Index: test/CodeGenObjCXX/encode.mm
===
--- test/CodeGenObjCXX/encode.mm
+++ test/CodeGenObjCXX/encode.mm
@@ -242,6 +242,6 @@
 @end
 
 const char *expand_struct() {
-  // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] c"{N={S=^{N}}}\00"
+  // CHECK: @{{.*}} = private unnamed_addr constant [13 x i8] c"{N={S=@}}\00"
   return @encode(N);
 }
Index: test/CodeGenObjC/encode-test.m
===
--- test/CodeGenObjC/encode-test.m
+++ test/CodeGenObjC/encode-test.m
@@ -107,7 +107,7 @@
 // CHECK: @g4 = constant [6 x i8] c"{S=i}\00"
 const char g4[] = @encode(const struct S);
 
-// CHECK: @g5 = constant [12 x i8] c"^{Object=#}\00"
+// CHECK: @g5 = constant [2 x i8] c"@\00"
 const char g5[] = @encode(MyObj * const);
 
 
Index: test/CodeGenObjC/encode-test-6.m
===
--- test/CodeGenObjC/encode-test-6.m
+++ test/CodeGenObjC/encode-test-6.m
@@ -34,7 +34,7 @@
 @synthesize property = _property;
 @end
 
-// CHECK: private unnamed_addr constant [24 x i8] c"^{BABugExample=@}16
+// CHECK: private unnamed_addr constant [8 x i8] c"@16
 
 // rdar://14408244
 @class SCNCamera;
@@ -52,7 +52,7 @@
 C3DCameraStorage _storage;
 }
 @end
-// CHECK: private unnamed_addr constant [39 x i8] c"{?=\22presentationInstance\22^{SCNCamera}}\00"
+// CHECK: private unnamed_addr constant [39 x i8] c"{?=\22presentationInstance\22@\22SCNCamera\22}\00"
 
 // rdar://16655340
 int i;
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -6927,13 +6927,10 @@
   getObjCEncodingForTypeImpl(Field->getType(), S,
  ObjCEncOptions().setExpandStructures(),
  Field);
-else {
-  ObjCEncOptions NewOptions = ObjCEncOptions().setExpandStructures();
-  if (Options.EncodePointerToObjCTypedef())
-NewOptions.setEncodePointerToObjCTypedef();
-  getObjCEncodingForTypeImpl(Field->getType(), S, NewOptions, FD,
+else
+  getObjCEncodingForTypeImpl(Field->getType(), S,
+ ObjCEncOptions().setExpandStructures(), FD,
  NotEncodedT);
-}
   }
 }
 S += '}';
@@ -6976,36 +6973,6 @@
   return;
 }
 
-QualType PointeeTy = OPT->getPointeeType();
-if (!Options.EncodingProperty() &&
-isa(PointeeTy.getTypePtr()) &&
-!Options.EncodePointerToObjCTypedef()) {
-  // Another historical/compatibility reason.
-  // We encode the underlying type which comes out as
-  // {...};
-  S += '^';
-  if (FD && OPT->getInterfaceDecl()) {
-// Prevent recursive encoding of fields in some rare cases.
-ObjCInterfaceDecl *OI = OPT->getInterfaceDecl();
-SmallVector Ivars;
-DeepCollectObjCIvars(OI, true, Ivars);
-for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
-  if (Ivars[i] == FD) {
-S += '{';
-S += OI->getObjCRuntimeNameAsString();
-S += '}';
-return;
-  }
-}
-  }
-  ObjCEncOptions NewOptions =
-  ObjCEncOptions().setEncodePointerToObjCTypedef();
-  if (Options.ExpandPointedToStructures())
-NewOptions.setExpandStructures();
-  getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions, /*Field=*/nullptr);
-  return;
-}
-
 S += '@';
 if (OPT->getInterfaceDecl() &&
 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -2897,7 +2897,6 @@
   V(IsStructField, 4)  \
   V(EncodeBlockParameters, 5)  \
   V(EncodeClassNames, 6)   \
-  V(EncodePointerToObjCTypedef, 7)
 
 #define V(N,I) ObjCEncOptions& set##N() { Bits |= 1 << I; return *this; }
 OPT_LIST(V)
@@ -2916,8 +2915,7 @@
 LLVM_NODISCARD ObjCEncOptions forComponentType() const {
   ObjCEncOptions Mask = ObjCEncOptions()
 .setIsOutermostType()
-

[PATCH] D62045: Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-28 Thread Yaqi Ji via Phabricator via cfe-commits
yaqiji added a comment.

Yes please, thank you :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



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


[PATCH] D62550: [coroutines][PR41909] Don't build dependent coroutine statements for generic lambda

2019-05-28 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
modocache added reviewers: GorNishanov, EricWF, lewissbaker, tks2103.
Herald added a project: clang.

https://bugs.llvm.org/show_bug.cgi?id=41909 describes an issue in which
a generic lambda that takes a dependent argument `auto set` causes the
template instantiation machinery for coroutine body statements to crash
with an ICE. The issue is two-fold:

1. The paths taken by the template instantiator contain several asserts that 
the coroutine promise must not have a dependent type.
2. The template instantiator unconditionally builds corotuine statements that 
depend on the promise type, which cannot be dependent.

To work around the issue, prevent the template instantiator from building
dependent coroutine statements if the coroutine promise type is dependent.
Since we only expect this to occur in the case of a generic lambda, limit
the workaround behavior to just that case.


Repository:
  rC Clang

https://reviews.llvm.org/D62550

Files:
  lib/Sema/TreeTransform.h
  test/SemaCXX/coroutines.cpp


Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -720,6 +720,16 @@
   co_await 42;
 }
 
+template void ok_generic_lambda_coawait_PR41909() {
+  [](auto& arg) -> coro { // expected-warning {{expression 
result unused}}
+co_await 12;
+  };
+  [](auto ) -> coro {
+co_await 24;
+  }("argument");
+}
+template void ok_generic_lambda_coawait_PR41909(); // expected-note {{in 
instantiation of function template specialization 
'ok_generic_lambda_coawait_PR41909' requested here}}
+
 template<> struct std::experimental::coroutine_traits
 { using promise_type = promise; };
 
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -7155,13 +7155,22 @@
   Builder.ReturnValue = Res.get();
 
   if (S->hasDependentPromiseType()) {
-assert(!Promise->getType()->isDependentType() &&
-   "the promise type must no longer be dependent");
-assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
-   !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
-   "these nodes should not have been built yet");
-if (!Builder.buildDependentStatements())
-  return StmtError();
+// PR41909: We may find a generic coroutine lambda definition within a
+// template function that is being instantiated. In this case, the lambda
+// will have a dependent promise type, until it is used in an expression
+// that creates an instantiation with a non-dependent promise type. We
+// should not assert or build coroutine dependent statements for such a
+// generic lambda.
+auto *MD = dyn_cast_or_null(FD);
+if (!MD || !MD->getParent()->isGenericLambda()) {
+  assert(!Promise->getType()->isDependentType() &&
+ "the promise type must no longer be dependent");
+  assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
+ !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
+ "these nodes should not have been built yet");
+  if (!Builder.buildDependentStatements())
+return StmtError();
+}
   } else {
 if (auto *OnFallthrough = S->getFallthroughHandler()) {
   StmtResult Res = getDerived().TransformStmt(OnFallthrough);


Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -720,6 +720,16 @@
   co_await 42;
 }
 
+template void ok_generic_lambda_coawait_PR41909() {
+  [](auto& arg) -> coro { // expected-warning {{expression result unused}}
+co_await 12;
+  };
+  [](auto ) -> coro {
+co_await 24;
+  }("argument");
+}
+template void ok_generic_lambda_coawait_PR41909(); // expected-note {{in instantiation of function template specialization 'ok_generic_lambda_coawait_PR41909' requested here}}
+
 template<> struct std::experimental::coroutine_traits
 { using promise_type = promise; };
 
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -7155,13 +7155,22 @@
   Builder.ReturnValue = Res.get();
 
   if (S->hasDependentPromiseType()) {
-assert(!Promise->getType()->isDependentType() &&
-   "the promise type must no longer be dependent");
-assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
-   !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
-   "these nodes should not have been built yet");
-if (!Builder.buildDependentStatements())
-  return StmtError();
+// PR41909: We may find a generic coroutine lambda definition within a
+// template function that is being instantiated. In this case, the lambda
+// will have a dependent promise type, 

[PATCH] D62271: [Driver] Fix -working-directory issues

2019-05-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rC Clang

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

https://reviews.llvm.org/D62271



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


[PATCH] D62045: Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-28 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

It looks like all concerns have been addressed. Do you need me to land this 
commit for you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



___
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-05-28 Thread Xing Xue via Phabricator via cfe-commits
xingxue marked an inline comment as done.
xingxue added inline comments.



Comment at: libcxx/include/stdint.h:16
+#endif // _STD_TYPES_T
 
 /*

hubert.reinterpretcast wrote:
> mclow.lists wrote:
> > I don't think that this will do what you want it to.
> > Is this a supported use case?
> > 
> > ```
> > #include 
> > #define _STD_TYPES_T
> > #include 
> > ```
> > 
> > 
> The comment is perhaps not clear. We need `` to be re-enterable 
> only as long as all previous inclusions have occurred while `_STD_TYPES_T` is 
> defined. The effect of including `` without defining `_STD_TYPES_T` 
> is a strict superset of the effects of including `` in other 
> circumstances. Should we adjust the comment?
Updated comments as suggested. This patch helps scenarios such as the following 
on `AIX`.

 #include 
 #include 

where ``  included in the first line defines macro `_STD_TYPES_T`, 
includes ``, and then undefines `_STD_TYPES_T`. `` included 
in the second line can be entered to get to macros such as `UINT32_MAX`. Since 
`_STD_TYPES_T` is undefined with the second inclusion, the header guard macro 
is defined and `` is no longer re-enterable.


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] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-05-28 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

One more thing.

On macOS FSEvents are coalesced more or less at will and it became quite 
apparent when I was creating automatic tests - I was for example receiving 
coalesced events Added & Modified & Removed. We had a discussion about how to 
deal with this and it turned out that the existing client doesn't actually care 
whether a file was created or whether it was modified. I believe that by 
removing the EventKind::Added we still keep the interface sane while removing 
the ambiguity.


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

https://reviews.llvm.org/D58418



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


[PATCH] D62493: [Driver] Always use Unix-style paths in the Darwin driver

2019-05-28 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D62493#1519708 , @rnk wrote:

> So, there's nothing wrong, functionally speaking, with what we do today, 
> right? It's just inconvenient to test.


What we do for Darwin today (without this patch) is functionally correct, but 
hard to test.

What we do for other platforms (e.g. Linux) today is probably not correct, 
since we use Unix-style paths all around the place.

> The difficulty of testing the driver has been a long standing problem. I 
> think we might want to instead invent some new kind of alternative to `-###` 
> for writing driver tests that is more FileCheck friendly. For example, we 
> could print flags one-per line, without quoting. I think it would also be 
> reasonable to do some dumb string post-processing to rewrite Windows-style 
> paths to Unix style paths so they always look the same.

Would it make sense to be able to define FileCheck variables (with `-DFOO`) 
while giving them a type? If I could specify that I'm passing paths to 
FileCheck and it normalized them for the platform the tests are being run on, I 
think that would solve the issue. Do you think that's an idea worth pursuing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62493



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


[PATCH] D48680: Add missing visibility annotation for __base

2019-05-28 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

More specifically, the following program always causes the vtable for 
`__base` to be internal:

  cat <
  
  int go(float) { return 0; }
  std::function foo() { return go; }
  
  int main() { foo()(3.3f); }
  EOF

That's true with or without this patch, and with or without 
`-fvisibility=hidden`. We always get:

  ...
   U vtable for __cxxabiv1::__si_class_type_info
  00013178 s vtable for std::__1::__function::__base
  000130f0 s vtable for std::__1::__function::__func, int (float)>
  00013218 s vtable for std::__1::bad_function_call
  ...


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D48680



___
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-05-28 Thread Xing Xue via Phabricator via cfe-commits
xingxue updated this revision to Diff 201746.
xingxue added a comment.

Updated comments explaining the scenario of the changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59253

Files:
  clang/lib/Headers/inttypes.h
  clang/lib/Headers/stdint.h
  libcxx/include/inttypes.h
  libcxx/include/stdint.h
  libcxx/test/std/depr/depr.c.headers/stdint_h.sh.cpp

Index: libcxx/test/std/depr/depr.c.headers/stdint_h.sh.cpp
===
--- /dev/null
+++ libcxx/test/std/depr/depr.c.headers/stdint_h.sh.cpp
@@ -0,0 +1,268 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// AIX system headers need stdint.h to be re-enterable when macro _STD_TYPES_T
+// is defined. This test case tests that after including sys/types.h which
+// defines macro _STD_TYPES_T, includes stdint.h, and then undefines
+// _STD_TYPES_T, stdint.h can be entered to get to macros like UINT32_MAX.
+//
+// REQUIRES: aix
+// RUN: %compile -c
+// RUN: %compile -c -D_XOPEN_SOURCE=700
+
+// test 
+//
+// Test that limits macros are available when  is included with
+// or without macro _XOPEN_SOUECE=700.
+
+#include 
+#include 
+
+#ifndef INT8_MIN
+#error INT8_MIN not defined
+#endif
+
+#ifndef INT16_MIN
+#error INT16_MIN not defined
+#endif
+
+#ifndef INT32_MIN
+#error INT32_MIN not defined
+#endif
+
+#ifndef INT64_MIN
+#error INT64_MIN not defined
+#endif
+
+#ifndef INT8_MAX
+#error INT8_MAX not defined
+#endif
+
+#ifndef INT16_MAX
+#error INT16_MAX not defined
+#endif
+
+#ifndef INT32_MAX
+#error INT32_MAX not defined
+#endif
+
+#ifndef INT64_MAX
+#error INT64_MAX not defined
+#endif
+
+#ifndef UINT8_MAX
+#error UINT8_MAX not defined
+#endif
+
+#ifndef UINT16_MAX
+#error UINT16_MAX not defined
+#endif
+
+#ifndef UINT32_MAX
+#error UINT32_MAX not defined
+#endif
+
+#ifndef UINT64_MAX
+#error UINT64_MAX not defined
+#endif
+
+#ifndef INT_LEAST8_MIN
+#error INT_LEAST8_MIN not defined
+#endif
+
+#ifndef INT_LEAST16_MIN
+#error INT_LEAST16_MIN not defined
+#endif
+
+#ifndef INT_LEAST32_MIN
+#error INT_LEAST32_MIN not defined
+#endif
+
+#ifndef INT_LEAST64_MIN
+#error INT_LEAST64_MIN not defined
+#endif
+
+#ifndef INT_LEAST8_MAX
+#error INT_LEAST8_MAX not defined
+#endif
+
+#ifndef INT_LEAST16_MAX
+#error INT_LEAST16_MAX not defined
+#endif
+
+#ifndef INT_LEAST32_MAX
+#error INT_LEAST32_MAX not defined
+#endif
+
+#ifndef INT_LEAST64_MAX
+#error INT_LEAST64_MAX not defined
+#endif
+
+#ifndef UINT_LEAST8_MAX
+#error UINT_LEAST8_MAX not defined
+#endif
+
+#ifndef UINT_LEAST16_MAX
+#error UINT_LEAST16_MAX not defined
+#endif
+
+#ifndef UINT_LEAST32_MAX
+#error UINT_LEAST32_MAX not defined
+#endif
+
+#ifndef UINT_LEAST64_MAX
+#error UINT_LEAST64_MAX not defined
+#endif
+
+#ifndef INT_FAST8_MIN
+#error INT_FAST8_MIN not defined
+#endif
+
+#ifndef INT_FAST16_MIN
+#error INT_FAST16_MIN not defined
+#endif
+
+#ifndef INT_FAST32_MIN
+#error INT_FAST32_MIN not defined
+#endif
+
+#ifndef INT_FAST64_MIN
+#error INT_FAST64_MIN not defined
+#endif
+
+#ifndef INT_FAST8_MAX
+#error INT_FAST8_MAX not defined
+#endif
+
+#ifndef INT_FAST16_MAX
+#error INT_FAST16_MAX not defined
+#endif
+
+#ifndef INT_FAST32_MAX
+#error INT_FAST32_MAX not defined
+#endif
+
+#ifndef INT_FAST64_MAX
+#error INT_FAST64_MAX not defined
+#endif
+
+#ifndef UINT_FAST8_MAX
+#error UINT_FAST8_MAX not defined
+#endif
+
+#ifndef UINT_FAST16_MAX
+#error UINT_FAST16_MAX not defined
+#endif
+
+#ifndef UINT_FAST32_MAX
+#error UINT_FAST32_MAX not defined
+#endif
+
+#ifndef UINT_FAST64_MAX
+#error UINT_FAST64_MAX not defined
+#endif
+
+#ifndef INTPTR_MIN
+#error INTPTR_MIN not defined
+#endif
+
+#ifndef INTPTR_MAX
+#error INTPTR_MAX not defined
+#endif
+
+#ifndef UINTPTR_MAX
+#error UINTPTR_MAX not defined
+#endif
+
+#ifndef INTMAX_MIN
+#error INTMAX_MIN not defined
+#endif
+
+#ifndef INTMAX_MAX
+#error INTMAX_MAX not defined
+#endif
+
+#ifndef UINTMAX_MAX
+#error UINTMAX_MAX not defined
+#endif
+
+#ifndef PTRDIFF_MIN
+#error PTRDIFF_MIN not defined
+#endif
+
+#ifndef PTRDIFF_MAX
+#error PTRDIFF_MAX not defined
+#endif
+
+#ifndef SIG_ATOMIC_MIN
+#error SIG_ATOMIC_MIN not defined
+#endif
+
+#ifndef SIG_ATOMIC_MAX
+#error SIG_ATOMIC_MAX not defined
+#endif
+
+#ifndef SIZE_MAX
+#error SIZE_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WINT_MIN
+#error WINT_MIN not defined
+#endif
+
+#ifndef WINT_MAX
+#error WINT_MAX not defined
+#endif
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+

[PATCH] D48680: Add missing visibility annotation for __base

2019-05-28 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

What I don't understand is under which circumstances this changes anything, 
since we don't export `__base` from the dylib, and implicit instantiations of 
`__base` don't cause it to be exported. Can you please provide a sample program 
where this changes what's exported, or the LTO visibility you're mentioning?


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D48680



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


[PATCH] D62525: [Analyzer] Add new visitor to the iterator checkers

2019-05-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D62525#1519475 , 
@baloghadamsoftware wrote:

> Before someone asks: `NoteTag`s are not applicable here since invalidation 
> and reaching one end of the range happens in many different places. This is 
> also true for container emptiness.


Mm, what's wrong with many different places? If you're worried about code 
duplication, just put tag construction into a function (?)




Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:281-282
+
+  // `FoundChange` becomes true when we find the statement the results in the
+  // current state of the iterator.
+  // `FoundEmptyness` becomes true when we find the block edge assuming

I don't think we should stop here. I think it's worth it to highlight *all* 
increments and decrements of the interesting iterator, so that it was clear how 
come that it has the given value.

Additionally, because iterators are copied around, it makes sense to 
"recursively" apply the visitor to the original object when the iterator is 
obtained as a copy (similarly to how `trackExpressionValue` works).


Repository:
  rC Clang

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

https://reviews.llvm.org/D62525



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


[PATCH] D61809: [BPF] Preserve debuginfo array/union/struct type/access index

2019-05-28 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@rsmith @eli.friedman Do you have any comments on the clang intrinsic interface 
in this patch and the llvm intrinsics interface at 
https://reviews.llvm.org/D61810?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61809



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


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-05-28 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 201744.
jkorous added a comment.

Remove DirectoryWatcher::Event::EventKind::Added


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

https://reviews.llvm.org/D58418

Files:
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/CMakeLists.txt
  clang/lib/DirectoryWatcher/CMakeLists.txt
  clang/lib/DirectoryWatcher/DirectoryScanner.cpp
  clang/lib/DirectoryWatcher/DirectoryScanner.h
  clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/DirectoryWatcher/CMakeLists.txt
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- /dev/null
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -0,0 +1,425 @@
+//===- unittests/DirectoryWatcher/DirectoryWatcherTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/DirectoryWatcher/DirectoryWatcher.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Mutex.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace llvm::sys;
+using namespace llvm::sys::fs;
+using namespace clang;
+
+namespace clang {
+static bool operator==(const DirectoryWatcher::Event ,
+   const DirectoryWatcher::Event ) {
+  return lhs.Filename == rhs.Filename &&
+ static_cast(lhs.Kind) == static_cast(rhs.Kind);
+}
+} // namespace clang
+
+namespace {
+
+struct DirectoryWatcherTestFixture {
+  std::string TestRootDir;
+  std::string TestWatchedDir;
+
+  DirectoryWatcherTestFixture() {
+SmallString<128> pathBuf;
+std::error_code UniqDirRes = createUniqueDirectory("dirwatcher", pathBuf);
+assert(!UniqDirRes);
+TestRootDir = pathBuf.str();
+path::append(pathBuf, "watch");
+TestWatchedDir = pathBuf.str();
+std::error_code CreateDirRes = create_directory(TestWatchedDir, false);
+assert(!CreateDirRes);
+  }
+
+  ~DirectoryWatcherTestFixture() { remove_directories(TestRootDir); }
+
+  SmallString<128> getPathInWatched(const std::string ) {
+SmallString<128> pathBuf;
+pathBuf = TestWatchedDir;
+path::append(pathBuf, testFile);
+return pathBuf;
+  }
+
+  void addFile(const std::string ) {
+Expected ft = openNativeFileForWrite(getPathInWatched(testFile),
+ CD_CreateNew, OF_None);
+if (ft) {
+  closeFile(*ft);
+} else {
+  llvm::errs() << llvm::toString(ft.takeError()) << "\n";
+  llvm::errs() << getPathInWatched(testFile) << "\n";
+  llvm_unreachable("Couldn't create test file.");
+}
+  }
+
+  void deleteFile(const std::string ) {
+std::error_code EC =
+remove(getPathInWatched(testFile), /*IgnoreNonExisting=*/false);
+ASSERT_FALSE(EC);
+  }
+};
+
+std::string EventKindToString(const DirectoryWatcher::Event::EventKind K) {
+  switch (K) {
+  case DirectoryWatcher::Event::EventKind::Removed:
+return "Removed";
+  case DirectoryWatcher::Event::EventKind::Modified:
+return "Modified";
+  case DirectoryWatcher::Event::EventKind::WatchedDirRemoved:
+return "WatchedDirRemoved";
+  case DirectoryWatcher::Event::EventKind::WatcherGotInvalidated:
+return "WatcherGotInvalidated";
+  }
+  llvm_unreachable("unknown event kind");
+}
+
+struct VerifyingConsumer {
+  std::vector ExpectedInitial;
+  std::vector ExpectedNonInitial;
+  std::vector OptionalNonInitial;
+  std::vector UnexpectedInitial;
+  std::vector UnexpectedNonInitial;
+  std::mutex Mtx;
+  std::condition_variable ResultIsReady;
+
+  VerifyingConsumer(
+  const std::vector ,
+  const std::vector ,
+  const std::vector  = {})
+  : ExpectedInitial(ExpectedInitial),
+ExpectedNonInitial(ExpectedNonInitial),
+OptionalNonInitial(OptionalNonInitial) {}
+
+  // This method is used by DirectoryWatcher
+  void consume(DirectoryWatcher::Event E, bool IsInitial) {
+if (IsInitial)
+  consumeInitial(E);
+else
+  consumeNonInitial(E);
+  }
+
+  void consumeInitial(DirectoryWatcher::Event E) {
+std::unique_lock L(Mtx);
+auto It = std::find(ExpectedInitial.begin(), ExpectedInitial.end(), E);
+if (It == ExpectedInitial.end()) {
+  UnexpectedInitial.push_back(E);
+} else {
+  ExpectedInitial.erase(It);
+}
+if (Result())
+  ResultIsReady.notify_one();
+  }
+
+  void consumeNonInitial(DirectoryWatcher::Event E) {
+std::unique_lock L(Mtx);
+auto It = 

[PATCH] D62533: Build with _XOPEN_SOURCE defined on AIX

2019-05-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: llvm/CMakeLists.txt:862
+# Build with _XOPEN_SOURCE on AIX, as stray macros in _ALL_SOURCE mode tend to
+# break things. In this case we need to enable the LARGE FILE API as well
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")

Use either "code" or English style: `s/LARGE FILE API/large-file API/;`.
Add a period to the end of the sentence.



Comment at: llvm/cmake/config-ix.cmake:27
+# Do checks with _XOPEN_SOURCE and LARGE FILE API on AIX, as we will build with
+# that too
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")

Same comment as above regarding "LARGE FILE API".
Use "because" in place of "as", and replace "that" with "those".
Add a period to the end of the sentence.



Comment at: llvm/utils/unittest/CMakeLists.txt:33
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+remove_definitions("-D_XOPEN_SOURCE=700")
+endif()

Indent only two spaces.



Comment at: llvm/utils/unittest/googletest/src/gtest-port.cc:62
 #if GTEST_OS_AIX
+#define _ALL_SOURCE
 # include 

It's generally a bad idea to define such macros after system headers have 
already been included.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62533



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


[PATCH] D61509: [OpenMP] Set pragma start loc to `#pragma` loc

2019-05-28 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361867: [OpenMP] Set pragma start loc to `#pragma` loc 
(authored by jdenny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61509?vs=198491=201741#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61509

Files:
  cfe/trunk/lib/Parse/ParsePragma.cpp
  cfe/trunk/test/AST/ast-dump-openmp-atomic.c
  cfe/trunk/test/AST/ast-dump-openmp-barrier.c
  cfe/trunk/test/AST/ast-dump-openmp-cancel.c
  cfe/trunk/test/AST/ast-dump-openmp-cancellation-point.c
  cfe/trunk/test/AST/ast-dump-openmp-critical.c
  cfe/trunk/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-distribute-parallel-for.c
  cfe/trunk/test/AST/ast-dump-openmp-distribute-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-distribute.c
  cfe/trunk/test/AST/ast-dump-openmp-flush.c
  cfe/trunk/test/AST/ast-dump-openmp-for-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-for.c
  cfe/trunk/test/AST/ast-dump-openmp-master.c
  cfe/trunk/test/AST/ast-dump-openmp-ordered.c
  cfe/trunk/test/AST/ast-dump-openmp-parallel-for-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-parallel-for.c
  cfe/trunk/test/AST/ast-dump-openmp-parallel-sections.c
  cfe/trunk/test/AST/ast-dump-openmp-parallel.c
  cfe/trunk/test/AST/ast-dump-openmp-section.c
  cfe/trunk/test/AST/ast-dump-openmp-sections.c
  cfe/trunk/test/AST/ast-dump-openmp-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-single.c
  cfe/trunk/test/AST/ast-dump-openmp-target-data.c
  cfe/trunk/test/AST/ast-dump-openmp-target-enter-data.c
  cfe/trunk/test/AST/ast-dump-openmp-target-exit-data.c
  cfe/trunk/test/AST/ast-dump-openmp-target-parallel-for-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-target-parallel-for.c
  cfe/trunk/test/AST/ast-dump-openmp-target-parallel.c
  cfe/trunk/test/AST/ast-dump-openmp-target-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  cfe/trunk/test/AST/ast-dump-openmp-target-teams-distribute-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-target-teams-distribute.c
  cfe/trunk/test/AST/ast-dump-openmp-target-teams.c
  cfe/trunk/test/AST/ast-dump-openmp-target-update.c
  cfe/trunk/test/AST/ast-dump-openmp-target.c
  cfe/trunk/test/AST/ast-dump-openmp-task.c
  cfe/trunk/test/AST/ast-dump-openmp-taskgroup.c
  cfe/trunk/test/AST/ast-dump-openmp-taskloop-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-taskloop.c
  cfe/trunk/test/AST/ast-dump-openmp-taskwait.c
  cfe/trunk/test/AST/ast-dump-openmp-taskyield.c
  cfe/trunk/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  cfe/trunk/test/AST/ast-dump-openmp-teams-distribute-simd.c
  cfe/trunk/test/AST/ast-dump-openmp-teams-distribute.c
  cfe/trunk/test/AST/ast-dump-openmp-teams.c
  cfe/trunk/test/AST/dump.cpp
  cfe/trunk/test/OpenMP/parallel_codegen.cpp
  cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
  cfe/trunk/test/PCH/stmt-openmp_structured_block-bit.cpp
  clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp



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


[clang-tools-extra] r361867 - [OpenMP] Set pragma start loc to `#pragma` loc

2019-05-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue May 28 12:27:19 2019
New Revision: 361867

URL: http://llvm.org/viewvc/llvm-project?rev=361867=rev
Log:
[OpenMP] Set pragma start loc to `#pragma` loc

This patch adjusts `PragmaOpenMPHandler` to set the location of
`tok::annot_pragma_openmp` to the `#pragma` location instead of the
`omp` location so that the former becomes the start location of the
OpenMP AST node.  This can be useful when, for example, rewriting a
directive using Clang's Rewrite facility.  Most of this patch updates
tests for changes to locations in diagnostics and `-ast-dump` output.

Reviewed By: ABataev, lebedev.ri, Meinersbur, aaron.ballman

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

Modified:
clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp?rev=361867=361866=361867=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp Tue May 
28 12:27:19 2019
@@ -23,7 +23,7 @@ void n0(const int a) {
 void p0_0() {
 #pragma omp parallel
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'parallel' does 
not specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' does 
not specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'parallel' directive can have 'default' clause, and said clause specified,
@@ -38,7 +38,7 @@ void p0_1() {
 void p0_2() {
 #pragma omp parallel default(shared)
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'parallel' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 
instead
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 
instead
   // CHECK-NOTES: :[[@LINE-3]]:22: note: existing 'default' clause specified 
here
 }
 
@@ -49,7 +49,7 @@ void p0_2() {
 void p1_0() {
 #pragma omp task
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'task' does not 
specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' does not 
specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'task' directive can have 'default' clause, and said clause specified,
@@ -64,7 +64,7 @@ void p1_1() {
 void p1_2() {
 #pragma omp task default(shared)
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'task' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
   // CHECK-NOTES: :[[@LINE-3]]:18: note: existing 'default' clause specified 
here
 }
 
@@ -76,7 +76,7 @@ void p2_0() {
 #pragma omp target
 #pragma omp teams
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'teams' does not 
specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'teams' does not 
specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'teams' directive can have 'default' clause, and said clause specified,
@@ -93,7 +93,7 @@ void p2_2() {
 #pragma omp target
 #pragma omp teams default(shared)
   ;
-  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'teams' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'teams' specifies 
'default(shared)' clause, consider using 'default(none)' clause instead
   // CHECK-NOTES: :[[@LINE-3]]:19: note: existing 'default' clause specified 
here
 }
 
@@ -105,7 +105,7 @@ void p3_0(const int a) {
 #pragma omp taskloop
   for (int b = 0; b < a; b++)
 ;
-  // CHECK-NOTES: :[[@LINE-3]]:9: warning: OpenMP directive 'taskloop' does 
not specify 'default' clause, consider specifying 'default(none)' clause
+  // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'taskloop' does 
not specify 'default' clause, consider specifying 'default(none)' clause
 }
 
 // 'taskloop' directive can have 'default' clause, and said clause specified,
@@ -122,7 +122,7 @@ void p3_2(const int a) {
 #pragma omp taskloop default(shared)
   for (int b = 0; b < a; b++)
 ;
-  // CHECK-NOTES: :[[@LINE-3]]:9: warning: OpenMP directive 'taskloop' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 
instead
+  // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'taskloop' 
specifies 'default(shared)' clause, consider using 'default(none)' clause 

[PATCH] D62413: [OpenCL][PR41727] Prevent ICE on global dtors

2019-05-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGDeclCXX.cpp:132
+  Argument = CGM.getTargetCodeGenInfo().performAddrSpaceCast(
+  CGM, Addr.getPointer(), SrcAS, LangAS::opencl_global, DestTy);
 

Should this code be conditional to OpenCL?  And why does `_cxa_atexit` take a 
`__global` pointer instead of, say, a `__generic` one?


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

https://reviews.llvm.org/D62413



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


[PATCH] D61974: [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/AST/ASTContext.cpp:6975
-isa(PointeeTy.getTypePtr()) &&
-!Options.EncodePointerToObjCTypedef()) {
-  // Another historical/compatibility reason.

Is this option dead now?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61974



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


[PATCH] D48680: Add missing visibility annotation for __base

2019-05-28 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.
Herald added a subscriber: libcxx-commits.

Hi Peter and Marshall,

Yunlian has moved to a different project. Can you let me know what is missing 
in this patch so that it can be submitted.


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D48680



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


[PATCH] D62493: [Driver] Always use Unix-style paths in the Darwin driver

2019-05-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

So, there's nothing wrong, functionally speaking, with what we do today, right? 
It's just inconvenient to test.

The difficulty of testing the driver has been a long standing problem. I think 
we might want to instead invent some new kind of alternative to `-###` for 
writing driver tests that is more FileCheck friendly. For example, we could 
print flags one-per line, without quoting. I think it would also be reasonable 
to do some dumb string post-processing to rewrite Windows-style paths to Unix 
style paths so they always look the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62493



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


r361859 - Driver: support `/Zc:char8_t` and `/Zc:char8_t-`

2019-05-28 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue May 28 11:26:00 2019
New Revision: 361859

URL: http://llvm.org/viewvc/llvm-project?rev=361859=rev
Log:
Driver: support `/Zc:char8_t` and `/Zc:char8_t-`

Update the `cl` emulation to support the `/Zc:char8_t[-]?` options as per the
MSVC 2019.1 toolset.  These are aliases for `-fchar8_t` and `-fno-char8_t`.

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=361859=361858=361859=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Tue May 28 11:26:00 2019
@@ -3051,6 +3051,8 @@ Execute ``clang-cl /?`` to see a list of
   /Yc   Generate a pch file for all code up to and 
including 
   /Yu   Load a pch file and use it instead of all code 
up to and including 
   /Z7 Enable CodeView debug information in object files
+  /Zc:char8_t Enable C++2a char8_t type
+  /Zc:char8_t-Disable C++2a char8_t type
   /Zc:dllexportInlines-   Don't dllexport/dllimport inline member 
functions of dllexport/import classes
   /Zc:dllexportInlinesdllexport/dllimport inline member functions of 
dllexport/import classes (default)
   /Zc:sizedDealloc-   Disable C++14 sized global deallocation functions

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=361859=361858=361859=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue May 28 11:26:00 2019
@@ -212,6 +212,12 @@ def _SLASH_Zc_alignedNew : CLFlag<"Zc:al
 def _SLASH_Zc_alignedNew_ : CLFlag<"Zc:alignedNew-">,
   HelpText<"Disable C++17 aligned allocation functions">,
   Alias;
+def _SLASH_Zc_char8_t : CLFlag<"Zc:char8_t">,
+  HelpText<"Enable char8_t from C++2a">,
+  Alias;
+def _SLASH_Zc_char8_t_ : CLFlag<"Zc:char8_t-">,
+  HelpText<"Disable char8_t from c++2a">,
+  Alias;
 def _SLASH_Zc_strictStrings : CLFlag<"Zc:strictStrings">,
   HelpText<"Treat string literals as const">, Alias,
   AliasArgs<["error=c++11-compat-deprecated-writable-strings"]>;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=361859=361858=361859=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue May 28 11:26:00 2019
@@ -326,6 +326,13 @@
 // RUN: %clang_cl -c /Zc:twoPhase -### -- %s 2>&1 | FileCheck 
-check-prefix=DELAYEDOFF %s
 // DELAYEDOFF-NOT: "-fdelayed-template-parsing"
 
+// RUN: %clang_cl -c -### /std:c++latest -- %s 2>&1 | FileCheck -check-prefix 
CHECK-LATEST-CHAR8_T %s
+// CHECK-LATEST-CHAR8_T-NOT: "-fchar8_t"
+// RUN: %clang_cl -c -### /Zc:char8_t -- %s 2>&1 | FileCheck -check-prefix 
CHECK-CHAR8_T %s
+// CHECK-CHAR8_T: "-fchar8_t"
+// RUN: %clang_cl -c -### /Zc:char8_t- -- %s 2>&1 | FileCheck -check-prefix 
CHECK-CHAR8_T_ %s
+// CHECK-CHAR8_T_: "-fno-char8_t"
+
 // For some warning ids, we can map from MSVC warning to Clang warning.
 // RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck 
-check-prefix=Wno %s
 // Wno: "-cc1"


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


[PATCH] D62538: [clangd] Add hidden tweaks to dump AST/selection.

2019-05-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
mgorny.
Herald added a project: clang.

This introduces a few new concepts:

- tweaks have an Intent (they don't all advertise as refactorings)
- tweaks may produce messages (for ShowMessage notification). Generalized 
Replacements -> Effect.
- tweaks (and other features) may be hidden (clangd -hidden-features flag). We 
may choose to promote these one day. I'm not sure they're worth their own 
feature flags though.

Verified it in vim-clangd (not yet open source), curious if the UI is ok in 
VSCode.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D62538

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/refactor/Tweak.h
  clangd/refactor/tweaks/CMakeLists.txt
  clangd/refactor/tweaks/DumpAST.cpp
  clangd/refactor/tweaks/RawStringLiteral.cpp
  clangd/refactor/tweaks/SwapIfBranches.cpp
  clangd/tool/ClangdMain.cpp
  clangd/unittests/TweakTests.cpp

Index: clangd/unittests/TweakTests.cpp
===
--- clangd/unittests/TweakTests.cpp
+++ clangd/unittests/TweakTests.cpp
@@ -16,12 +16,12 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock-matchers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
 
 using llvm::Failed;
-using llvm::HasValue;
 using llvm::Succeeded;
 
 namespace clang {
@@ -76,7 +76,8 @@
 void checkNotAvailable(StringRef ID, llvm::StringRef Input) {
   return checkAvailable(ID, Input, /*Available=*/false);
 }
-llvm::Expected apply(StringRef ID, llvm::StringRef Input) {
+
+llvm::Expected apply(StringRef ID, llvm::StringRef Input) {
   Annotations Code(Input);
   Range SelectionRng;
   if (Code.points().size() != 0) {
@@ -98,15 +99,30 @@
   auto T = prepareTweak(ID, S);
   if (!T)
 return T.takeError();
-  auto Replacements = (*T)->apply(S);
-  if (!Replacements)
-return Replacements.takeError();
-  return applyAllReplacements(Code.code(), *Replacements);
+  return (*T)->apply(S);
+}
+
+llvm::Expected applyEdit(StringRef ID, llvm::StringRef Input) {
+  auto Effect = apply(ID, Input);
+  if (!Effect)
+return Effect.takeError();
+  if (!Effect->ApplyEdit)
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "No replacements");
+  Annotations Code(Input);
+  return applyAllReplacements(Code.code(), *Effect->ApplyEdit);
+}
+
+std::string getMessage(StringRef ID, llvm::StringRef Input) {
+  auto Effect = apply(ID, Input);
+  if (!Effect)
+return "error: " + llvm::toString(Effect.takeError());
+  return Effect->ShowMessage.getValueOr("no message produced!");
 }
 
 void checkTransform(llvm::StringRef ID, llvm::StringRef Input,
 std::string Output) {
-  auto Result = apply(ID, Input);
+  auto Result = applyEdit(ID, Input);
   ASSERT_TRUE(bool(Result)) << llvm::toString(Result.takeError()) << Input;
   EXPECT_EQ(Output, std::string(*Result)) << Input;
 }
@@ -217,6 +233,37 @@
   checkTransform(ID, Input, Output);
 }
 
+TEST(TweakTest, DumpAST) {
+  llvm::StringLiteral ID = "DumpAST";
+
+  checkAvailable(ID, "^int f^oo() { re^turn 2 ^+ 2; }");
+  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));
+}
+
+TEST(TweakTest, ShowSelectionTree) {
+  llvm::StringLiteral ID = "ShowSelectionTree";
+
+  checkAvailable(ID, "^int f^oo() { re^turn 2 ^+ 2; }");
+  checkNotAvailable(ID, "/*c^omment*/ int foo() return 2 ^ + 2; }");
+
+  const char *Input = "int fcall(int); int x = fca[[ll(2 +]]2);";
+  const char *Output = R"(TranslationUnitDecl 
+  VarDecl int x = fcall(2 + 2)
+   .CallExpr fcall(2 + 2)
+  ImplicitCastExpr fcall
+   .DeclRefExpr fcall
+ .BinaryOperator 2 + 2
+   *IntegerLiteral 2
+)";
+  EXPECT_EQ(Output, getMessage(ID, Input));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -268,6 +268,11 @@
 "Always used text-based completion")),
 llvm::cl::init(CodeCompleteOptions().RunParser), llvm::cl::Hidden);
 
+static llvm::cl::opt HiddenFeatures(
+"hidden-features",
+llvm::cl::desc("Enable hidden features mostly useful to clangd developers"),
+llvm::cl::init(false), llvm::cl::Hidden);
+
 namespace {
 
 /// \brief Supports a test URI scheme with relaxed constraints for lit tests.
@@ -465,6 +470,7 @@
   }
   Opts.StaticIndex = 

[PATCH] D61974: [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D61974



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


[PATCH] D61742: [Driver][Windows] Add dependent lib argument for profile instr generate

2019-05-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Since this seems to work with no-canonical-prefixes, I think this is good as-is 
since people who want build path independent builds need that flag anyway. (At 
least if Russel can reproduce it working with no-canonical-prefixes; not sure 
why it wouldn't.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D61742



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


[PATCH] D61742: [Driver][Windows] Add dependent lib argument for profile instr generate

2019-05-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D61742#1519539 , @russell.gallop 
wrote:

> > I was going to suggest that maybe what we should do is just embed the 
> > basename, i.e. /nodefaultlib:clang_rt.profile-x86_64.lib ...
>
> Do you mean /defaultlib:clang_rt.profile-x86_64.lib?
>
> > ... and then we just ask users to add one /libpath: flag to their linker 
> > invocation
>
> I'll try that. If it works, should we revisit the ubsan dependent lib 
> support, to be consistent?


Yes, definitely. I'd like to do the same for asan, but things there are 
complicated by the various CRT linking modes.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61742



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


[PATCH] D61742: [Driver][Windows] Add dependent lib argument for profile instr generate

2019-05-28 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

> I was going to suggest that maybe what we should do is just embed the 
> basename, i.e. /nodefaultlib:clang_rt.profile-x86_64.lib ...

Do you mean /defaultlib:clang_rt.profile-x86_64.lib?

> ... and then we just ask users to add one /libpath: flag to their linker 
> invocation

I'll try that. If it works, should we revisit the ubsan dependent lib support, 
to be consistent?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61742



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


[PATCH] D62333: Fix unresolved symbols when linking tools/clang/unittests/Tooling/ToolingTests

2019-05-28 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum marked 2 inline comments as done.
quantum added inline comments.



Comment at: cfe/trunk/unittests/Tooling/CMakeLists.txt:4
   Support
   TestingSupport
   )

thakis wrote:
> The library is already up here. Why do we need it twice?
We don't. It's removed in the code that's merged.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62333



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


[PATCH] D60748: Fix i386 struct and union parameter alignment

2019-05-28 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Yes, LGTM.


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

https://reviews.llvm.org/D60748



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


[PATCH] D62167: CodeView - add static data members to global variable debug info.

2019-05-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added subscribers: manmanren, probinson.
rnk added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4385
+// Use the global scope for static members.
+DContext = getContextDescriptor(
+   cast(CGM.getContext().getTranslationUnitDecl()), TheCU);

akhuang wrote:
> akhuang wrote:
> > dblaikie wrote:
> > > akhuang wrote:
> > > > @dblaikie I'm using the global scope here because if the class type is 
> > > > used as the scope it runs into the [[ 
> > > > https://github.com/llvm/llvm-project/blob/a2ee80b084e5c0b20364ed4379384706f5e059b1/llvm/lib/IR/DIBuilder.cpp#L630
> > > >  | assert message ]] `Context of a global variable should not be a type 
> > > > with identifier`. Is there a reason for the assert? 
> > > I think it's generally how LLVM handles definitions for the most part - 
> > > putting them at the global scope.
> > > 
> > > Though I'm confused by this patch - it has a source change in clang, but 
> > > a test in LLVM. Generally there should be testing to cover where the 
> > > source change is, I think?
> > yep, there should be a test for this - added now. 
> So for the global scope, it seems like [[ 
> https://github.com/llvm-mirror/clang/blob/900624ef605b60c613342dac071228539a402ce9/lib/CodeGen/CGDebugInfo.cpp#L3274
>  | elsewhere ]], when creating the debug info for a static data member global 
> variable, the scope is set to be the global scope. But it would be helpful 
> for codeview debug info if the scope remained as the class type, partially so 
> we can use the class type information in the variable name that we emit.
> 
> Does it seem reasonable to remove the assert for global variable scope so 
> that the scope can be the class here?
I think the assertion in question is this one here in DIBuilder:
https://github.com/llvm/llvm-project/blob/master/llvm/lib/IR/DIBuilder.cpp#L634

It looks like @manmanren added this in 2014:
https://github.com/llvm/llvm-project/commit/bfd2b829d912ecd89f73ae32d4c683856dd677a3

@dblaikie do you know if this check is still necessary? It seems like the DWARF 
clang generages today corresponds to C++ written this way:
```
struct Foo { static const int Test2; };
const int Foo::Test2 = 4;
```
When oftentimes the source looks more like this:
```
struct Foo { static const int Test2 = 4; };
```
I saw a conversation between you and @probinson fixing clang irgen to avoid 
this assert sometime back, so I figured you might be a good point of reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62167



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


[PATCH] D62035: [AST] const-ify ObjC inherited class search

2019-05-28 Thread Ben Gertzfield via Phabricator via cfe-commits
beng added a comment.

Thanks! @jyknight might want to take a look (this seems fine to me though).


Repository:
  rC Clang

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

https://reviews.llvm.org/D62035



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


[PATCH] D62533: Build with _XOPEN_SOURCE defined on AIX

2019-05-28 Thread David Tenty via Phabricator via cfe-commits
daltenty created this revision.
daltenty added reviewers: hubert.reinterpretcast, xingxue, andusy.
daltenty added projects: LLVM, clang.
Herald added subscribers: llvm-commits, cfe-commits, jsji, mgorny.

It is useful to build with _XOPEN_SOURCE defined on AIX, enabling X/Open
and POSIX compatibility mode, to work around stray macros and other
bugs in the headers provided by the system and build compiler.

This patch adds the config to cmake to build with _XOPEN_SOURCE defined on AIX 
with a few exceptions. Google Test internals require access to platform 
specific thread info constructs on AIX so in that case we build with 
_ALL_SOURCE defined instead. Libclang also uses header which needs _ALL_SOURCE 
on AIX so we leave that as is as well..

We also add building on AIX with the large file API and doing CMake header 
checks with X/OPEN definitions so the results are consistent with the 
environment that will be present in the build.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62533

Files:
  clang/tools/libclang/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/utils/unittest/CMakeLists.txt
  llvm/utils/unittest/googletest/src/gtest-port.cc


Index: llvm/utils/unittest/googletest/src/gtest-port.cc
===
--- llvm/utils/unittest/googletest/src/gtest-port.cc
+++ llvm/utils/unittest/googletest/src/gtest-port.cc
@@ -59,6 +59,7 @@
 #endif  // GTEST_OS_QNX
 
 #if GTEST_OS_AIX
+#define _ALL_SOURCE
 # include 
 # include 
 #endif  // GTEST_OS_AIX
Index: llvm/utils/unittest/CMakeLists.txt
===
--- llvm/utils/unittest/CMakeLists.txt
+++ llvm/utils/unittest/CMakeLists.txt
@@ -28,6 +28,11 @@
   add_definitions(-DGTEST_OS_WINDOWS=1)
 endif()
 
+# Google Test requires headers which need _ALL_SOURCE to build on AIX
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+remove_definitions("-D_XOPEN_SOURCE=700")
+endif()
+
 if(SUPPORTS_VARIADIC_MACROS_FLAG)
   add_definitions("-Wno-variadic-macros")
 endif()
Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -23,6 +23,13 @@
   list(APPEND CMAKE_REQUIRED_LIBRARIES "cxxrt")
 endif()
 
+# Do checks with _XOPEN_SOURCE and LARGE FILE API on AIX, as we will build with
+# that too
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE=700")
+  list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_LARGE_FILE_API")
+endif()
+
 # include checks
 check_include_file(dlfcn.h HAVE_DLFCN_H)
 check_include_file(errno.h HAVE_ERRNO_H)
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -858,6 +858,13 @@
 "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}")
 endif()
 
+# Build with _XOPEN_SOURCE on AIX, as stray macros in _ALL_SOURCE mode tend to
+# break things. In this case we need to enable the LARGE FILE API as well
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  add_definitions("-D_XOPEN_SOURCE=700")
+  add_definitions("-D_LARGE_FILE_API")
+endif()
+
 # Work around a broken bfd ld behavior. When linking a binary with a
 # foo.so library, it will try to find any library that foo.so uses and
 # check its symbols. This is wasteful (the check was done when foo.so
Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -89,6 +89,11 @@
   set(output_name "clang")
 endif()
 
+# libclang requires headers which need _ALL_SOURCE to build on AIX
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+remove_definitions("-D_XOPEN_SOURCE=700")
+endif()
+
 add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC}
   OUTPUT_NAME ${output_name}
   ${SOURCES}


Index: llvm/utils/unittest/googletest/src/gtest-port.cc
===
--- llvm/utils/unittest/googletest/src/gtest-port.cc
+++ llvm/utils/unittest/googletest/src/gtest-port.cc
@@ -59,6 +59,7 @@
 #endif  // GTEST_OS_QNX
 
 #if GTEST_OS_AIX
+#define _ALL_SOURCE
 # include 
 # include 
 #endif  // GTEST_OS_AIX
Index: llvm/utils/unittest/CMakeLists.txt
===
--- llvm/utils/unittest/CMakeLists.txt
+++ llvm/utils/unittest/CMakeLists.txt
@@ -28,6 +28,11 @@
   add_definitions(-DGTEST_OS_WINDOWS=1)
 endif()
 
+# Google Test requires headers which need _ALL_SOURCE to build on AIX
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+remove_definitions("-D_XOPEN_SOURCE=700")
+endif()
+
 if(SUPPORTS_VARIADIC_MACROS_FLAG)
   add_definitions("-Wno-variadic-macros")
 endif()
Index: llvm/cmake/config-ix.cmake

[PATCH] D62525: [Analyzer] Add new visitor to the iterator checkers

2019-05-28 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Before someone asks: `NoteTag`s are not applicable here since invalidation and 
reaching one end of the range happens in many different places. This is also 
true for container emptiness.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62525



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


[PATCH] D58920: [Modules][PR39287] Consolidate multiple std's

2019-05-28 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

@rsmith, what do you think of the patch as-is?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58920



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


[PATCH] D62035: [AST] const-ify ObjC inherited class search

2019-05-28 Thread Adam Ernst via Phabricator via cfe-commits
adamjernst added a comment.

@beng (hello!!) I've spotted you reviewing some Objective-C clang stuff … can 
you review, or do you have advice on a qualified reviewer?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62035



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


[PATCH] D62005: [libunwind] [test] Fix inferring source paths

2019-05-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping. Could somebody review this, please? It's blocking NetBSD buildbot for 
quite some time already.


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D62005



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


[PATCH] D50147: clang-format: support external styles

2019-05-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 201693.
Typz marked 3 inline comments as done.
Typz added a comment.
Herald added subscribers: ormris, mgorny.

- Rebased
- Adapt styles search path to platform conventions
- Allow customizing search path at compile time
- Allow overriding search path at runtime through CLANG_FORMAT_STYLES_PATH env 
variable


Repository:
  rC Clang

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

https://reviews.llvm.org/D50147

Files:
  include/clang/Format/Format.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -13185,6 +13185,124 @@
   ASSERT_EQ(*Style1, getGoogleStyle());
 }
 
+namespace {
+class EnvSetter {
+StringRef m_key;
+Optional m_oldValue;
+public:
+EnvSetter(StringRef key, StringRef value = StringRef()) : m_key(key) {
+  if (const char *oldValue = ::getenv(m_key.data()))
+m_oldValue.emplace(oldValue);
+  if (value.empty())
+::unsetenv(m_key.data());
+  else
+::setenv(m_key.data(), value.data(), 1);
+}
+~EnvSetter() {
+  if (m_oldValue)
+::setenv(m_key.data(), m_oldValue.getValue().data(), 1);
+}
+EnvSetter(const EnvSetter &) = delete;
+EnvSetter =(const EnvSetter &) = delete;
+};
+}
+
+TEST(FormatStyle, GetExternalStyle) {
+  // Override HOME environment variable to make tests independant of actual user
+  EnvSetter homeEnv("HOME", "/home");
+
+  // Clear CLANG_FORMAT_STYLES_PATH environment variable
+  EnvSetter stylesPathEnv("CLANG_FORMAT_STYLES_PATH");
+
+  llvm::vfs::InMemoryFileSystem FS;
+
+  // Test 1: format file in /usr/local/share/clang-format/
+  ASSERT_TRUE(
+  FS.addFile("/usr/local/share/clang-format/style1", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  auto Style1 = getStyle("style1", "", "LLVM", "", );
+  ASSERT_TRUE((bool)Style1);
+  ASSERT_EQ(*Style1, getGoogleStyle());
+
+  // Test 2: format file in /usr/share/clang-format/
+  ASSERT_TRUE(
+  FS.addFile("/usr/share/clang-format/style2", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  auto Style2 = getStyle("style2", "", "LLVM", "", );
+  ASSERT_TRUE((bool)Style2);
+  ASSERT_EQ(*Style2, getGoogleStyle());
+
+  // Test 3: format file in ~/.local/share/clang-format/
+  ASSERT_TRUE(
+  FS.addFile("/home/.local/share/clang-format/style3", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  auto Style3 = getStyle("style3", "", "LLVM", "", );
+  ASSERT_TRUE((bool)Style3);
+  ASSERT_EQ(*Style3, getGoogleStyle());
+
+  // Test 4: format file in absolute path
+  ASSERT_TRUE(
+  FS.addFile("/clang-format-styles/style4", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  auto Style4 = getStyle("/clang-format-styles/style4", "", "LLVM", "", );
+  ASSERT_TRUE((bool)Style4);
+  ASSERT_EQ(*Style4, getGoogleStyle());
+
+  // Test 5: format file in relative path
+  ASSERT_TRUE(
+  FS.addFile("/clang-format-styles/style5", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  FS.setCurrentWorkingDirectory("/clang-format-styles");
+  auto Style5 = getStyle("style5", "", "LLVM", "", );
+  ASSERT_TRUE((bool)Style5);
+  ASSERT_EQ(*Style5, getGoogleStyle());
+  FS.setCurrentWorkingDirectory("/");
+
+  // Test 6: file does not exist
+  auto Style6 = getStyle("style6", "", "LLVM", "", );
+  ASSERT_FALSE((bool)Style6);
+  llvm::consumeError(Style6.takeError());
+
+  // Test 7: absolute file does not exist
+  auto Style7 = getStyle("/style7", "", "LLVM", "", );
+  ASSERT_FALSE((bool)Style7);
+  llvm::consumeError(Style7.takeError());
+
+  // Test 8: file is not a format style
+  ASSERT_TRUE(
+  FS.addFile("/usr/local/share/clang-format/nostyle", 0,
+ llvm::MemoryBuffer::getMemBuffer("This is not a style...")));
+  FS.setCurrentWorkingDirectory("/home/clang-format-styles");
+  auto Style8 = getStyle("nostyle", "", "LLVM", "", );
+  ASSERT_FALSE((bool)Style8);
+  llvm::consumeError(Style8.takeError());
+
+  {
+// Override styles path
+EnvSetter customStylesPathEnv("CLANG_FORMAT_STYLES_PATH", "/customPath1:/customPath2");
+
+// Test 8: file in custom styles path
+ASSERT_TRUE(
+FS.addFile("/customPath1/style8_1", 0,
+   llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+auto Style8_1 = getStyle("style8_1", "", "LLVM", "", );
+ASSERT_TRUE((bool)Style8_1);
+ASSERT_EQ(*Style8_1, getGoogleStyle());
+
+ASSERT_TRUE(
+FS.addFile("/customPath2/style8_2", 0,
+   llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Mozilla")));
+auto Style8_2 = getStyle("style8_2", "", "LLVM", "", );
+ASSERT_TRUE((bool)Style8_2);
+

[PATCH] D61742: [Driver][Windows] Add dependent lib argument for profile instr generate

2019-05-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I was going to suggest that maybe what we should do is just embed the basename, 
i.e. `/nodefaultlib:clang_rt.profile-x86_64.lib`, and then we just ask users to 
add one `/libpath:` flag to their linker invocation. That saves users from 
having to come up with a mapping from their build system CPU name to whatever 
compiler-rt is using (i686, i386, x86-64, x86_64h, etc). Users should probably 
put clang's library directory on libpath anyway if they want to be able to find 
the builtins library, which might be necessary even in a standard (no-pgo, 
no-coverage) build configuration. This is also consistent with MSVC in some 
ways, which autolinks the CRT this way.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61742



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


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

2019-05-28 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Are the behavior differences between the newpm alwaysinliner and the oldpm 
alwaysinliner intentional?  Specifically, the differences in pass remarks, and 
the differences in the treatment of the alwaysinline attribute seem suspect.  
(I'm not that interested in the different bitcasts and different order of 
inline allocas, although that might be nice to fix if it's a small change.)


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


  1   2   >