[PATCH] D74961: [clangd] Make global rename file limit adjustable

2020-02-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev abandoned this revision.
kbobyrev added a comment.

In D74961#1886479 , @hokein wrote:

> oops, I should have synced with you first (the task was assigned to me in the 
> Tuesday meeting), I have https://reviews.llvm.org/D74834 which is under 
> review. Apology for this.
>
> Maybe you subscribe all clangd patches in phabricator as well (to allow 
> better tracking), since most of our teammates have already done it.


No worries, I should've talked to you first! Thanks for working on this!


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

https://reviews.llvm.org/D74961



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


[PATCH] D75022: clang-format: Extend AllowShortLoopsOnASingleLine to do ... while loops.

2020-02-24 Thread Daan De Meyer via Phabricator via cfe-commits
DaanDeMeyer updated this revision to Diff 246150.

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

https://reviews.llvm.org/D75022

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -404,7 +404,7 @@
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
 }
-if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while)) {
+if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do)) {
   return Style.AllowShortLoopsOnASingleLine
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
@@ -449,7 +449,7 @@
   return 0;
 Limit = limitConsideringMacros(I + 1, E, Limit);
 AnnotatedLine &Line = **I;
-if (Line.Last->isNot(tok::r_paren))
+if (!Line.First->is(tok::kw_do) && Line.Last->isNot(tok::r_paren))
   return 0;
 if (1 + I[1]->Last->TotalLength > Limit)
   return 0;


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -404,7 +404,7 @@
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
 }
-if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while)) {
+if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do)) {
   return Style.AllowShortLoopsOnASingleLine
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
@@ -449,7 +449,7 @@
   return 0;
 Limit = limitConsideringMacros(I + 1, E, Limit);
 AnnotatedLine &Line = **I;
-if (Line.Last->isNot(tok::r_paren))
+if (!Line.First->is(tok::kw_do) && Line.Last->isNot(tok::r_paren))
   return 0;
 if (1 + I[1]->Last->TotalLength > Limit)
   return 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-02-24 Thread Maximilian Fickert via Phabricator via cfe-commits
fickert created this revision.
fickert added reviewers: clang-format, MyDeveloperDay, krasimir.
fickert added projects: clang-format, clang-tools-extra.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Use spaces instead of tabs for alignment with UT_ForContinuationAndIndentation 
to make the code aligned for any tab/indent width.

Fixes https://bugs.llvm.org/show_bug.cgi?id=38381


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75034

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/ContinuationIndenter.h
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10139,7 +10139,7 @@
   verifyFormat("class X {\n"
"\tvoid f() {\n"
"\t\tsomeFunction(parameter1,\n"
-   "\t\t\t parameter2);\n"
+   "\t\t parameter2);\n"
"\t}\n"
"};",
Tab);
@@ -10155,7 +10155,7 @@
   verifyFormat("class TabWidth4Indent8 {\n"
"\t\tvoid f() {\n"
"\t\t\t\tsomeFunction(parameter1,\n"
-   "\t\t\t\t\t\t\t parameter2);\n"
+   "\t\t\t\t parameter2);\n"
"\t\t}\n"
"};",
Tab);
@@ -10164,7 +10164,7 @@
   verifyFormat("class TabWidth4Indent4 {\n"
"\tvoid f() {\n"
"\t\tsomeFunction(parameter1,\n"
-   "\t\t\t\t\t parameter2);\n"
+   "\t\t parameter2);\n"
"\t}\n"
"};",
Tab);
@@ -10173,15 +10173,15 @@
   verifyFormat("class TabWidth8Indent4 {\n"
"void f() {\n"
"\tsomeFunction(parameter1,\n"
-   "\t\t parameter2);\n"
+   "\t parameter2);\n"
"}\n"
"};",
Tab);
   Tab.TabWidth = 8;
   Tab.IndentWidth = 8;
   EXPECT_EQ("/*\n"
-"\t  a\t\tcomment\n"
-"\t  in multiple lines\n"
+"  a\t\tcomment\n"
+"  in multiple lines\n"
 "   */",
 format("   /*\t \t \n"
" \t \t a\t\tcomment\t \t\n"
@@ -10213,7 +10213,7 @@
   verifyFormat("class X {\n"
"\tvoid f() {\n"
"\t\tsomeFunction(parameter1,\n"
-   "\t\t\t parameter2);\n"
+   "\t\t parameter2);\n"
"\t}\n"
"};",
Tab);
@@ -10222,7 +10222,7 @@
"\t{\n"
"\t\tint a;\n"
"\t\tsomeFunction(,\n"
-   "\t\t\t\t bbb);\n"
+   "\t\t bbb);\n"
"\t},\n"
"\tp);\n"
"}",
@@ -10290,15 +10290,6 @@
"\t*/\n"
"}",
Tab));
-  EXPECT_EQ("/*\n"
-"\t  a\t\tcomment\n"
-"\t  in multiple lines\n"
-"   */",
-format("   /*\t \t \n"
-   " \t \t a\t\tcomment\t \t\n"
-   " \t \t in multiple lines\t\n"
-   " \t  */",
-   Tab));
   EXPECT_EQ("/* some\n"
 "   comment */",
 format(" \t \t /* some\n"
@@ -10331,6 +10322,29 @@
"\t */\n"
"\t int i;\n"
"}"));
+  Tab.TabWidth = 2;
+  Tab.IndentWidth = 2;
+  EXPECT_EQ("{\n"
+"\t/* \n"
+"\t    */\n"
+"}",
+format("{\n"
+   "/* \n"
+   "    */\n"
+   "}",
+   Tab));
+  EXPECT_EQ("{\n"
+"\t/*\n"
+"\t  aa\n"
+"\t  b\n"
+"\t*/\n"
+"}",
+format("{\n"
+   "/*\n"
+   "  aa b\n"
+   "*/\n"
+   "}",
+   Tab));
   Tab.AlignConsecutiveAssignments = true;
   Tab.AlignConsecutiveDeclarations = true;
   Tab.TabWidth = 4;
Index: clang/lib/Format/WhitespaceManager.h
===
--- clang/lib/Format/WhitespaceManager.h
+++ clang/lib/Format/WhitespaceManager.h
@@ -49,7 +49,7 @@
   /// this replacement. It is needed for determining how \p Spaces is turned
   /// into tabs and spaces for some format styles.
   void replaceWhitespace(FormatToken &Tok, unsigned Newlines, unsigned Spaces,

[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-02-24 Thread Maximilian Fickert via Phabricator via cfe-commits
fickert added a comment.

I added an `IsAligned` flag to `ParenState` and `Change` to track if an indent 
was created for alignment. I adapted the corresponding test cases where 
alignments were previously done with tabs, including a test case where leading 
whitespace in a comment is interpreted as alignment.

This is my first contribution to clang-format so I appreciate any suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75034



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


[PATCH] D74953: [profile] Don't dump counters when forking and don't reset when calling exec** functions

2020-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f46269f0c1c: [profile] Don't dump counters when 
forking and don't reset when calling exec**… (authored by Calixte Denizet 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74953

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/lib/profile/GCDAProfiling.c
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Index: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -115,7 +115,8 @@
   // list.
   Function *
   insertCounterWriteout(ArrayRef>);
-  Function *insertFlush(ArrayRef>);
+  Function *insertReset(ArrayRef>);
+  Function *insertFlush(Function *ResetF);
 
   void AddFlushBeforeForkAndExec();
 
@@ -631,35 +632,74 @@
 }
 
 void GCOVProfiler::AddFlushBeforeForkAndExec() {
-  SmallVector ForkAndExecs;
+  SmallVector, 2> ForkAndExecs;
   for (auto &F : M->functions()) {
 auto *TLI = &GetTLI(F);
 for (auto &I : instructions(F)) {
   if (CallInst *CI = dyn_cast(&I)) {
 if (Function *Callee = CI->getCalledFunction()) {
   LibFunc LF;
-  if (TLI->getLibFunc(*Callee, LF) &&
-  (LF == LibFunc_fork || LF == LibFunc_execl ||
-   LF == LibFunc_execle || LF == LibFunc_execlp ||
-   LF == LibFunc_execv || LF == LibFunc_execvp ||
-   LF == LibFunc_execve || LF == LibFunc_execvpe ||
-   LF == LibFunc_execvP)) {
-ForkAndExecs.push_back(&I);
+  if (TLI->getLibFunc(*Callee, LF)) {
+if (LF == LibFunc_fork) {
+#if !defined(_WIN32)
+  ForkAndExecs.push_back({true, CI});
+#endif
+} else if (LF == LibFunc_execl || LF == LibFunc_execle ||
+   LF == LibFunc_execlp || LF == LibFunc_execv ||
+   LF == LibFunc_execvp || LF == LibFunc_execve ||
+   LF == LibFunc_execvpe || LF == LibFunc_execvP) {
+  ForkAndExecs.push_back({false, CI});
+}
   }
 }
   }
 }
   }
 
-  // We need to split the block after the fork/exec call
-  // because else the counters for the lines after will be
-  // the same as before the call.
-  for (auto I : ForkAndExecs) {
-IRBuilder<> Builder(I);
-FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
-FunctionCallee GCOVFlush = M->getOrInsertFunction("__gcov_flush", FTy);
-Builder.CreateCall(GCOVFlush);
-I->getParent()->splitBasicBlock(I);
+  for (auto F : ForkAndExecs) {
+IRBuilder<> Builder(F.second);
+BasicBlock *Parent = F.second->getParent();
+auto NextInst = ++F.second->getIterator();
+
+if (F.first) {
+  // We've a fork so just reset the counters in the child process
+  FunctionType *FTy = FunctionType::get(Builder.getInt32Ty(), {}, false);
+  FunctionCallee GCOVFork = M->getOrInsertFunction("__gcov_fork", FTy);
+  F.second->setCalledFunction(GCOVFork);
+  if (NextInst != Parent->end()) {
+// We split just after the fork to have a counter for the lines after
+// Anyway there's a bug:
+// void foo() { fork(); }
+// void bar() { foo(); blah(); }
+// then "blah();" will be called 2 times but showed as 1
+// because "blah()" belongs to the same block as "foo();"
+Parent->splitBasicBlock(NextInst);
+
+// back() is a br instruction with a debug location
+// equals to the one from NextAfterFork
+// So to avoid to have two debug locs on two blocks just change it
+DebugLoc Loc = F.second->getDebugLoc();
+Parent->back().setDebugLoc(Loc);
+  }
+} else {
+  // Since the process is replaced by a new one we need to write out gcdas
+  // No need to reset the counters since they'll be lost after the exec**
+  FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
+  FunctionCallee WriteoutF =
+  M->getOrInsertFunction("llvm_writeout_files", FTy);
+  Builder.CreateCall(WriteoutF);
+  if (NextInst != Parent->end()) {
+DebugLoc Loc = F.second->getDebugLoc();
+Builder.SetInsertPoint(&*NextInst);
+// If the exec** fails we must reset the counters since they've been
+// dumped
+FunctionCallee ResetF =
+M->getOrInsertFunction("llvm_reset_counters", FTy);
+Builder.CreateCall(ResetF)->setDebugLoc(Loc);
+Parent->splitBasicBlock(NextInst);
+Parent->back().setDebugLoc(Loc);
+  }
+}
   }
 }
 
@@ -851,7 +891,8 @@
 }
 
 Function *WriteoutF = insertCounterWriteout(CountersBySP);
-Function *FlushF = insertFlush(CountersBySP);
+Function *ResetF = insertRese

[PATCH] D52136: [clang-tidy] Add modernize-concat-nested-namespaces check

2020-02-24 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added inline comments.



Comment at: clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp:88
+
+  if (!Sources.isInMainFile(ND.getBeginLoc()))
+return;

This breaks the usage of this checker in an unified build scenario since the 
main file for the translation unit will be the unified file. 


Repository:
  rL LLVM

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

https://reviews.llvm.org/D52136



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


[PATCH] D75006: Wrap lines for C# property accessors

2020-02-24 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 246170.
jbcoe added a comment.

Handle C# access modifier `internal `.

Fix typo in test for expression-bodied get/set methods.


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

https://reviews.llvm.org/D75006

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -554,5 +554,25 @@
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpPropertyAccessors) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(//
+int Value { get; set }
+string Name { get; private set }
+string AnotherName { protected get; private set }
+string YetAnotherName { internal get; internal set }
+double Sum { get })",
+   Style);
+
+  // Do not wrap expression body definitions.
+  verifyFormat(R"(//
+public string Name {
+  get => _name;
+  set => _name = value;
+})",
+   Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -292,6 +292,13 @@
   }
 }
 
+// Try to merge a CSharp property declaration like `{ get; private set }`.
+if (Style.isCSharp()) {
+  unsigned CSPA = tryMergeCSharpPropertyAccessor(I, E, Limit);
+  if (CSPA > 0)
+return CSPA;
+}
+
 // Try to merge a function block with left brace unwrapped
 if (TheLine->Last->is(TT_FunctionLBrace) &&
 TheLine->First != TheLine->Last) {
@@ -421,6 +428,53 @@
 return 0;
   }
 
+  unsigned tryMergeCSharpPropertyAccessor(
+  SmallVectorImpl::const_iterator I,
+  SmallVectorImpl::const_iterator E, unsigned /*Limit*/) {
+// Does line start with `{`
+if (I[0]->Last->isNot(TT_FunctionLBrace))
+  return 0;
+
+// Does line start with `[access-modifier] get`
+if (I + 1 == E)
+  return 0;
+auto *GetToken = I[1]->First;
+if (GetToken && GetToken->isOneOf(tok::kw_public, tok::kw_protected,
+  tok::kw_private, Keywords.kw_internal))
+  GetToken = GetToken->Next;
+if (!GetToken || GetToken->TokenText != "get")
+  return 0;
+// Keep `get => some_code;` on a single line.
+if (GetToken->Next && GetToken->Next->isNot(tok::semi))
+  return 0;
+
+// Does line start with `[access-modifier] set` or `{`
+if (I + 2 == E)
+  return 0;
+auto *SetToken = I[2]->First;
+if (SetToken && SetToken->isOneOf(tok::kw_public, tok::kw_protected,
+  tok::kw_private, Keywords.kw_internal))
+  SetToken = SetToken->Next;
+
+if (SetToken && SetToken->is(tok::r_brace))
+  return 2;
+
+if (!SetToken || SetToken->TokenText != "set")
+  return 0;
+// Keep `set => some_code;` on a single line.
+if (SetToken->Next)
+  return 0;
+
+// Does line start with `}`
+if (I + 3 == E)
+  return 0;
+auto *RBrace = I[3]->First;
+if (!RBrace || !RBrace->is(tok::r_brace))
+  return 0;
+
+return 3;
+  }
+
   unsigned
   tryMergeSimplePPDirective(SmallVectorImpl::const_iterator I,
 SmallVectorImpl::const_iterator E,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74833: [AArch64][SVE] Add intrinsics for SVE2 cryptographic instructions

2020-02-24 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf2ff153401fa: [AArch64][SVE] Add intrinsics for SVE2 
cryptographic instructions (authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D74833?vs=245393&id=246171#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74833

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-crypto.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-crypto.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-crypto.ll
@@ -0,0 +1,99 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2-aes,+sve2-sha3,+sve2-sm4 -asm-verbose=0 < %s | FileCheck %s
+
+;
+; AESD
+;
+
+define  @aesd_i8( %a,  %b) {
+; CHECK-LABEL: aesd_i8:
+; CHECK: aesd z0.b, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.aesd( %a,
+ %b)
+  ret  %out
+}
+
+;
+; AESIMC
+;
+
+define  @aesimc_i8( %a) {
+; CHECK-LABEL: aesimc_i8:
+; CHECK: aesimc z0.b, z0.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.aesimc( %a)
+  ret  %out
+}
+
+;
+; AESE
+;
+
+define  @aese_i8( %a,  %b) {
+; CHECK-LABEL: aese_i8:
+; CHECK: aese z0.b, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.aese( %a,
+ %b)
+  ret  %out
+}
+
+;
+; AESMC
+;
+
+define  @aesmc_i8( %a) {
+; CHECK-LABEL: aesmc_i8:
+; CHECK: aesmc z0.b, z0.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.aesmc( %a)
+  ret  %out
+}
+
+;
+; RAX1
+;
+
+define  @rax1_i64( %a,  %b) {
+; CHECK-LABEL: rax1_i64:
+; CHECK: rax1 z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.rax1( %a,
+ %b)
+  ret  %out
+}
+
+;
+; SM4E
+;
+
+define  @sm4e_i32( %a,  %b) {
+; CHECK-LABEL: sm4e_i32:
+; CHECK: sm4e z0.s, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sm4e( %a,
+ %b)
+  ret  %out
+}
+
+;
+; SM4EKEY
+;
+
+define  @sm4ekey_i32( %a,  %b) {
+; CHECK-LABEL: sm4ekey_i32:
+; CHECK: sm4ekey z0.s, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sm4ekey( %a,
+%b)
+  ret  %out
+}
+
+
+declare  @llvm.aarch64.sve.aesd(, )
+declare  @llvm.aarch64.sve.aesimc()
+declare  @llvm.aarch64.sve.aese(, )
+declare  @llvm.aarch64.sve.aesmc()
+declare  @llvm.aarch64.sve.rax1(, )
+declare  @llvm.aarch64.sve.sm4e(, )
+declare  @llvm.aarch64.sve.sm4ekey(, )
Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -7101,6 +7101,12 @@
   let Inst{4-0}   = Zd;
 }
 
+multiclass sve2_crypto_cons_bin_op {
+  def NAME : sve2_crypto_cons_bin_op;
+  def : SVE_2_Op_Pat(NAME)>;
+}
+
 class sve2_crypto_des_bin_op opc, string asm, ZPRRegOp zprty>
 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm),
   asm, "\t$Zdn, $_Zdn, $Zm",
@@ -7118,8 +7124,14 @@
   let Constraints = "$Zdn = $_Zdn";
 }
 
-class sve2_crypto_unary_op
-: I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn),
+multiclass sve2_crypto_des_bin_op opc, string asm, ZPRRegOp zprty,
+  SDPatternOperator op, ValueType vt> {
+  def NAME : sve2_crypto_des_bin_op;
+  def : SVE_2_Op_Pat(NAME)>;
+}
+
+class sve2_crypto_unary_op
+: I<(outs zprty:$Zdn), (ins zprty:$_Zdn),
   asm, "\t$Zdn, $_Zdn",
   "",
   []>, Sched<[]> {
@@ -7132,6 +7144,11 @@
   let Constraints = "$Zdn = $_Zdn";
 }
 
+multiclass sve2_crypto_unary_op {
+  def NAME : sve2_crypto_unary_op;
+  def : SVE_1_Op_Pat(NAME)>;
+}
+
 /// Addressing modes
 def am_sve_indexed_s4 :ComplexPattern", [], [SDNPWantRoot]>;
 def am_sve_indexed_s6 :ComplexPattern", [], [SDNPWantRoot]>;
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -1917,12 +1917,12 @@
 
 let Predicates = [HasSVE2AES] in {
   // SVE2 crypto destructive binary operations
-  def AESE_ZZZ_B : sve2_crypto_des_bin_op<0b00, "aese", ZPR8>;
-  def AESD_ZZZ_B : sve2_crypto_des_bin_op<0b01, "aesd", ZPR8>;
+  defm AESE_ZZZ_B : sve2_crypto_des_bin_op<0b00, "aese", ZPR8, int_aarch64_sve_aese, nxv16i8>;
+  defm AESD_ZZZ_B : sve2_crypto_des_bin_op<0b01, "aesd", ZPR8, int_aarch64_sve_aesd, nxv16i8>;
 
   // SVE2 crypto unary operations
-  def AESMC_ZZ_B  : sve2_crypto_unary_op<0b0, "aesmc">;
-  def AESIMC_ZZ_B : sve2_crypto_unary_op<0b1, "aesimc">;
+  defm AESMC_ZZ_B  : sve2_crypto_unary_op<0b0, "ae

[PATCH] D75038: [ARM,MVE] Remove 64-bit variants of vbrsrq* intrinsics

2020-02-24 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: simon_tatham, dmgreen, MarkMurrayARM, ostannard.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

According to the ACLE the vbrsrq* intrinsics don't accept vectors
with 64-bit elements (and neither does the corresponding VBRSR
instruction).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75038

Files:
  clang/include/clang/Basic/arm_mve.td


Index: clang/include/clang/Basic/arm_mve.td
===
--- clang/include/clang/Basic/arm_mve.td
+++ clang/include/clang/Basic/arm_mve.td
@@ -1310,7 +1310,7 @@
   }
 }
 
-let params = T.All in {
+let params = T.Usual in {
 let pnt = PNT_NType in
 def vbrsrq_n: Intrinsic $a, $b)>;


Index: clang/include/clang/Basic/arm_mve.td
===
--- clang/include/clang/Basic/arm_mve.td
+++ clang/include/clang/Basic/arm_mve.td
@@ -1310,7 +1310,7 @@
   }
 }
 
-let params = T.All in {
+let params = T.Usual in {
 let pnt = PNT_NType in
 def vbrsrq_n: Intrinsic $a, $b)>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75038: [ARM,MVE] Remove 64-bit variants of vbrsrq* intrinsics

2020-02-24 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham accepted this revision.
simon_tatham added a comment.
This revision is now accepted and ready to land.

... and we weren't //testing// the accidental 64-bit builtins (or else we'd 
have spotted the problem!), so no tests need to be changed. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75038



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


[PATCH] D75006: Wrap lines for C# property accessors

2020-02-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

This LGTM, thank you for the patch


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

https://reviews.llvm.org/D75006



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


[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-02-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

If you are changing unit tests then I'm nervous, imagine if this many tests 
change what the impact is on a large code base.  I think we need to understand 
more about why you are making this change and why you think its ok to 
change/remove existing tests which assert some behavior which up to now we have 
considered correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75034



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


[PATCH] D75022: clang-format: Extend AllowShortLoopsOnASingleLine to do ... while loops.

2020-02-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

You need to add unit tests


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

https://reviews.llvm.org/D75022



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


[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-02-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

you need to add any diff as a full context diff  (normally by adding -U 
999) to the diff command


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75034



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


[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-02-24 Thread Maximilian Fickert via Phabricator via cfe-commits
fickert updated this revision to Diff 246176.
fickert marked an inline comment as done.
fickert added a comment.

uploaded full context diff


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

https://reviews.llvm.org/D75034

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/ContinuationIndenter.h
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10139,7 +10139,7 @@
   verifyFormat("class X {\n"
"\tvoid f() {\n"
"\t\tsomeFunction(parameter1,\n"
-   "\t\t\t parameter2);\n"
+   "\t\t parameter2);\n"
"\t}\n"
"};",
Tab);
@@ -10155,7 +10155,7 @@
   verifyFormat("class TabWidth4Indent8 {\n"
"\t\tvoid f() {\n"
"\t\t\t\tsomeFunction(parameter1,\n"
-   "\t\t\t\t\t\t\t parameter2);\n"
+   "\t\t\t\t parameter2);\n"
"\t\t}\n"
"};",
Tab);
@@ -10164,7 +10164,7 @@
   verifyFormat("class TabWidth4Indent4 {\n"
"\tvoid f() {\n"
"\t\tsomeFunction(parameter1,\n"
-   "\t\t\t\t\t parameter2);\n"
+   "\t\t parameter2);\n"
"\t}\n"
"};",
Tab);
@@ -10173,15 +10173,15 @@
   verifyFormat("class TabWidth8Indent4 {\n"
"void f() {\n"
"\tsomeFunction(parameter1,\n"
-   "\t\t parameter2);\n"
+   "\t parameter2);\n"
"}\n"
"};",
Tab);
   Tab.TabWidth = 8;
   Tab.IndentWidth = 8;
   EXPECT_EQ("/*\n"
-"\t  a\t\tcomment\n"
-"\t  in multiple lines\n"
+"  a\t\tcomment\n"
+"  in multiple lines\n"
 "   */",
 format("   /*\t \t \n"
" \t \t a\t\tcomment\t \t\n"
@@ -10213,7 +10213,7 @@
   verifyFormat("class X {\n"
"\tvoid f() {\n"
"\t\tsomeFunction(parameter1,\n"
-   "\t\t\t parameter2);\n"
+   "\t\t parameter2);\n"
"\t}\n"
"};",
Tab);
@@ -10222,7 +10222,7 @@
"\t{\n"
"\t\tint a;\n"
"\t\tsomeFunction(,\n"
-   "\t\t\t\t bbb);\n"
+   "\t\t bbb);\n"
"\t},\n"
"\tp);\n"
"}",
@@ -10290,15 +10290,6 @@
"\t*/\n"
"}",
Tab));
-  EXPECT_EQ("/*\n"
-"\t  a\t\tcomment\n"
-"\t  in multiple lines\n"
-"   */",
-format("   /*\t \t \n"
-   " \t \t a\t\tcomment\t \t\n"
-   " \t \t in multiple lines\t\n"
-   " \t  */",
-   Tab));
   EXPECT_EQ("/* some\n"
 "   comment */",
 format(" \t \t /* some\n"
@@ -10331,6 +10322,29 @@
"\t */\n"
"\t int i;\n"
"}"));
+  Tab.TabWidth = 2;
+  Tab.IndentWidth = 2;
+  EXPECT_EQ("{\n"
+"\t/* \n"
+"\t    */\n"
+"}",
+format("{\n"
+   "/* \n"
+   "    */\n"
+   "}",
+   Tab));
+  EXPECT_EQ("{\n"
+"\t/*\n"
+"\t  aa\n"
+"\t  b\n"
+"\t*/\n"
+"}",
+format("{\n"
+   "/*\n"
+   "  aa b\n"
+   "*/\n"
+   "}",
+   Tab));
   Tab.AlignConsecutiveAssignments = true;
   Tab.AlignConsecutiveDeclarations = true;
   Tab.TabWidth = 4;
Index: clang/lib/Format/WhitespaceManager.h
===
--- clang/lib/Format/WhitespaceManager.h
+++ clang/lib/Format/WhitespaceManager.h
@@ -49,7 +49,7 @@
   /// this replacement. It is needed for determining how \p Spaces is turned
   /// into tabs and spaces for some format styles.
   void replaceWhitespace(FormatToken &Tok, unsigned Newlines, unsigned Spaces,
- unsigned StartOfTokenColumn,
+ unsigned StartOfTokenColumn, bool isAligned = false,
  bool InPPDirective = false);
 
   /// Adds information about an unchangeable to

[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-02-24 Thread Maximilian Fickert via Phabricator via cfe-commits
fickert added a comment.

I understand the caution around changing the unit tests. The tests I modified 
assumed that alignment would be made with mixed tabs and spaces, which is 
arguably not the expected behavior with `UT_ForContinuationAndIndentation` (see 
https://bugs.llvm.org/show_bug.cgi?id=38381).  I removed a test case that was a 
duplicate (the one in line 10293 is identical to the one in line 10182, and 
there are no changes to the formatting configuration in between). I added two 
test cases to ensure that the behavior is consistent for alignment in 
multi-line comments, e.g. the formatted code should be

  {
  \t/* 
  \t   
  }

instead of

  {
  \t/* 
  \t\t 
  }

when using `UT_ForContinuationAndIndentation` and a tab width of 2.


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

https://reviews.llvm.org/D75034



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


[clang] 12fed51 - [ARM, MVE] Remove 64-bit variants of vbrsrq* intrinsics

2020-02-24 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-02-24T12:49:20Z
New Revision: 12fed51c0807b0727f9eecdd3dcf774a82fa7ecd

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

LOG: [ARM,MVE] Remove 64-bit variants of vbrsrq* intrinsics

Summary:
According to the ACLE the vbrsrq* intrinsics don't accept vectors
with 64-bit elements (and neither does the corresponding VBRSR
instruction).

Reviewers: simon_tatham, dmgreen, MarkMurrayARM, ostannard

Reviewed By: simon_tatham

Subscribers: kristof.beyls, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/arm_mve.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index ca7246d78bd6..7150852d7004 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -1310,7 +1310,7 @@ foreach desttype = !listconcat(T.Int16, T.Int32, T.Float) 
in {
   }
 }
 
-let params = T.All in {
+let params = T.Usual in {
 let pnt = PNT_NType in
 def vbrsrq_n: Intrinsic $a, $b)>;



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


[PATCH] D74954: Add a basic tiling pass for parallel loops

2020-02-24 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer updated this revision to Diff 246167.
bkramer added a comment.
Herald added a subscriber: wuzish.
Herald added a reviewer: mclow.lists.

- WTF phab?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74954

Files:
  mlir/include/mlir/Dialect/LoopOps/Passes.h
  mlir/include/mlir/InitAllPasses.h
  mlir/lib/Dialect/LoopOps/Transforms/CMakeLists.txt
  mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopTiling.cpp
  mlir/test/Dialect/Loops/parallel-loop-tiling.mlir

Index: mlir/test/Dialect/Loops/parallel-loop-tiling.mlir
===
--- /dev/null
+++ mlir/test/Dialect/Loops/parallel-loop-tiling.mlir
@@ -0,0 +1,80 @@
+// RUN: mlir-opt %s -pass-pipeline='func(parallel-loop-tiling{parallel-loop-tile-sizes=1,4})' -split-input-file | FileCheck %s --dump-input-on-failure
+
+func @parallel_loop(%arg0 : index, %arg1 : index, %arg2 : index,
+%arg3 : index, %arg4 : index, %arg5 : index,
+		%A: memref, %B: memref,
+%C: memref, %result: memref) {
+  loop.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3) step (%arg4, %arg5) {
+%B_elem = load %B[%i0, %i1] : memref
+%C_elem = load %C[%i0, %i1] : memref
+%sum_elem = addf %B_elem, %C_elem : f32
+store %sum_elem, %result[%i0, %i1] : memref
+  }
+  return
+}
+
+// CHECK:   #map0 = affine_map<(d0, d1, d2) -> (d0, d1 - d2)>
+// CHECK-LABEL:   func @parallel_loop(
+// CHECK-SAME:[[VAL_0:%.*]]: index, [[VAL_1:%.*]]: index, [[VAL_2:%.*]]: index, [[VAL_3:%.*]]: index, [[VAL_4:%.*]]: index, [[VAL_5:%.*]]: index, [[VAL_6:%.*]]: memref, [[VAL_7:%.*]]: memref, [[VAL_8:%.*]]: memref, [[VAL_9:%.*]]: memref) {
+// CHECK:   [[VAL_10:%.*]] = constant 0 : index
+// CHECK:   [[VAL_11:%.*]] = constant 1 : index
+// CHECK:   [[VAL_12:%.*]] = constant 4 : index
+// CHECK:   [[VAL_13:%.*]] = muli [[VAL_4]], [[VAL_11]] : index
+// CHECK:   [[VAL_14:%.*]] = muli [[VAL_5]], [[VAL_12]] : index
+// CHECK:   loop.parallel ([[VAL_15:%.*]], [[VAL_16:%.*]]) = ([[VAL_0]], [[VAL_1]]) to ([[VAL_2]], [[VAL_3]]) step ([[VAL_13]], [[VAL_14]]) {
+// CHECK: [[VAL_17:%.*]] = affine.min #map0([[VAL_11]], [[VAL_2]], [[VAL_15]])
+// CHECK: [[VAL_18:%.*]] = affine.min #map0([[VAL_12]], [[VAL_3]], [[VAL_16]])
+// CHECK: loop.parallel ([[VAL_19:%.*]], [[VAL_20:%.*]]) = ([[VAL_10]], [[VAL_10]]) to ([[VAL_17]], [[VAL_18]]) step ([[VAL_4]], [[VAL_5]]) {
+// CHECK:   [[VAL_21:%.*]] = load [[VAL_7]]{{\[}}[[VAL_19]], [[VAL_20]]] : memref
+// CHECK:   [[VAL_22:%.*]] = load [[VAL_8]]{{\[}}[[VAL_19]], [[VAL_20]]] : memref
+// CHECK:   [[VAL_23:%.*]] = addf [[VAL_21]], [[VAL_22]] : f32
+// CHECK:   store [[VAL_23]], [[VAL_9]]{{\[}}[[VAL_19]], [[VAL_20]]] : memref
+// CHECK: }
+// CHECK:   }
+// CHECK:   return
+
+// -
+
+func @tile_nested_innermost() {
+  %c2 = constant 2 : index
+  %c0 = constant 0 : index
+  %c1 = constant 1 : index
+  loop.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) {
+loop.parallel (%k, %l) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) {
+}
+  }
+  loop.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) {
+  }
+  return
+}
+
+// CHECK-LABEL:   func @tile_nested_innermost() {
+// CHECK:   [[VAL_24:%.*]] = constant 2 : index
+// CHECK:   [[VAL_25:%.*]] = constant 0 : index
+// CHECK:   [[VAL_26:%.*]] = constant 1 : index
+// CHECK:   loop.parallel ([[VAL_27:%.*]], [[VAL_28:%.*]]) = ([[VAL_25]], [[VAL_25]]) to ([[VAL_24]], [[VAL_24]]) step ([[VAL_26]], [[VAL_26]]) {
+// CHECK: [[VAL_29:%.*]] = constant 0 : index
+// CHECK: [[VAL_30:%.*]] = constant 1 : index
+// CHECK: [[VAL_31:%.*]] = constant 4 : index
+// CHECK: [[VAL_32:%.*]] = muli [[VAL_26]], [[VAL_30]] : index
+// CHECK: [[VAL_33:%.*]] = muli [[VAL_26]], [[VAL_31]] : index
+// CHECK: loop.parallel ([[VAL_34:%.*]], [[VAL_35:%.*]]) = ([[VAL_25]], [[VAL_25]]) to ([[VAL_24]], [[VAL_24]]) step ([[VAL_32]], [[VAL_33]]) {
+// CHECK:   [[VAL_36:%.*]] = affine.min #map0([[VAL_30]], [[VAL_24]], [[VAL_34]])
+// CHECK:   [[VAL_37:%.*]] = affine.min #map0([[VAL_31]], [[VAL_24]], [[VAL_35]])
+// CHECK:   loop.parallel ([[VAL_38:%.*]], [[VAL_39:%.*]]) = ([[VAL_29]], [[VAL_29]]) to ([[VAL_36]], [[VAL_37]]) step ([[VAL_26]], [[VAL_26]]) {
+// CHECK:   }
+// CHECK: }
+// CHECK:   }
+// CHECK:   [[VAL_40:%.*]] = constant 0 : index
+// CHECK:   [[VAL_41:%.*]] = constant 1 : index
+// CHECK:   [[VAL_42:%.*]] = constant 4 : index
+// CHECK:   [[VAL_43:%.*]] = muli [[VAL_26]], [[VAL_41]] : index
+// CHECK:   [[VAL_44:%.*]] = muli [[VAL_26]], [[VAL_42

[PATCH] D74954: Add a basic tiling pass for parallel loops

2020-02-24 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer updated this revision to Diff 246166.
bkramer marked 4 inline comments as done.
bkramer added a comment.
Herald added subscribers: libc-commits, libcxx-commits, lldb-commits, 
Sanitizers, cfe-commits, bader, kerbowa, csigg, usaxena95, jdoerfert, ormris, 
jsji, kadircet, rupprecht, jfb, arphaman, dexonsmith, mgrang, jkorous, MaskRay, 
kbarton, aheejin, hiraditya, jgravelle-google, krytarowski, arichardson, 
sbc100, nhaehnle, jvesely, nemanjai, emaste, dschuff, arsenm.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: mravishankar.
Herald added a reviewer: antiagainst.
Herald added a reviewer: rriddle.
Herald added a reviewer: antiagainst.
Herald added a reviewer: uenoku.
Herald added projects: clang, Sanitizers, LLDB, libc++, libc-project.

- Address moar comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74954

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang-tools-extra/clangd/unittests/TweakTesting.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/test/CodeGen/codemodels.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/code-model.c
  clang/test/Driver/mbackchain.c
  clang/test/Driver/mcmodel.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/init-aarch64.c
  clang/test/Preprocessor/init.c
  clang/test/Sema/MicrosoftExtensions.c
  clang/test/Sema/cast.c
  clang/test/SemaCXX/cstyle-cast.cpp
  compiler-rt/lib/profile/GCDAProfiling.c
  libc/CMakeLists.txt
  libc/cmake/modules/LLVMLibCRules.cmake
  libc/docs/fuzzing.rst
  libc/docs/source_layout.rst
  libc/fuzzing/CMakeLists.txt
  libc/fuzzing/string/CMakeLists.txt
  libc/fuzzing/string/strcpy_fuzz.cpp
  libc/src/signal/linux/raise.cpp
  libc/utils/CPP/README.md
  libc/utils/HdrGen/README.md
  libc/utils/UnitTest/README.md
  libcxx/test/support/count_new.h
  libcxx/test/support/type_id.h
  lld/ELF/Writer.cpp
  lld/test/ELF/shuffle-sections-init-fini.s
  lld/test/ELF/shuffle-sections.s
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  lldb/test/API/lang/cpp/operators/main.cpp
  lldb/test/Shell/SymbolFile/Breakpad/Inputs/basic-elf.yaml
  lldb/test/Shell/SymbolFile/DWARF/dwp-debug-types.s
  lldb/test/Shell/SymbolFile/DWARF/dwp.s
  lldb/test/Shell/lit-lldb-init.in
  llvm/docs/Extensions.rst
  llvm/docs/LangRef.rst
  llvm/docs/LoopTerminology.rst
  llvm/include/llvm/ADT/STLExtras.h
  llvm/include/llvm/Analysis/CFGPrinter.h
  llvm/include/llvm/Analysis/LoopInfo.h
  llvm/include/llvm/CodeGen/GlobalISel/GISelKnownBits.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/ScoreboardHazardRecognizer.h
  llvm/include/llvm/CodeGen/SelectionDAG.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
  llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h
  llvm/include/llvm/ExecutionEngine/Orc/Core.h
  llvm/include/llvm/ExecutionEngine/Orc/OrcError.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/

[PATCH] D75040: [ASTMatchers] Adds a matcher called `hasAnyOperatorName`

2020-02-24 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
njames93 edited the summary of this revision.
njames93 added reviewers: aaron.ballman, gribozavr2.

Acts on `BinaryOperator` and `UnaryOperator` and functions the same as 
`anyOf(hasOperatorName(...), hasOperatorName(...), ...)`

Documentation generation isn't perfect but I feel that the python doc script 
needs updating for that


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75040

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1123,6 +1123,19 @@
   EXPECT_TRUE(notMatches("void x() { true && false; }", OperatorOr));
 }
 
+TEST(MatchBinaryOperator, HasAnyOperatorName) {
+  StatementMatcher Matcher =
+  binaryOperator(hasAnyOperatorName("+", "-", "*", "/"));
+
+  EXPECT_TRUE(matches("int x(int I) { return I + 2; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return I - 2; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return I * 2; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return I / 2; }", Matcher));
+  EXPECT_TRUE(notMatches("int x(int I) { return I % 2; }", Matcher));
+  // Ensure '+= isn't mistaken.
+  EXPECT_TRUE(notMatches("void x(int &I) { I += 1; }", Matcher));
+}
+
 TEST(MatchBinaryOperator, HasLHSAndHasRHS) {
   StatementMatcher OperatorTrueFalse =
 binaryOperator(hasLHS(cxxBoolLiteral(equals(true))),
@@ -1255,6 +1268,18 @@
   EXPECT_TRUE(notMatches("void x() { true; } ", OperatorNot));
 }
 
+TEST(MatchUnaryOperator, HasAnyOperatorName) {
+  StatementMatcher Matcher = unaryOperator(hasAnyOperatorName("-", "*", "++"));
+
+  EXPECT_TRUE(matches("int x(int *I) { return *I; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return -I; }", Matcher));
+  EXPECT_TRUE(matches("void x(int &I) { I++; }", Matcher));
+  EXPECT_TRUE(matches("void x(int &I) { ++I; }", Matcher));
+  EXPECT_TRUE(notMatches("void x(int &I) { I--; }", Matcher));
+  EXPECT_TRUE(notMatches("void x(int &I) { --I; }", Matcher));
+  EXPECT_TRUE(notMatches("int *x(int &I) { return &I; }", Matcher));
+}
+
 TEST(MatchUnaryOperator, HasUnaryOperand) {
   StatementMatcher OperatorOnFalse =
 unaryOperator(hasUnaryOperand(cxxBoolLiteral(equals(false;
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -243,6 +243,7 @@
   REGISTER_MATCHER(hasAnyConstructorInitializer);
   REGISTER_MATCHER(hasAnyDeclaration);
   REGISTER_MATCHER(hasAnyName);
+  REGISTER_MATCHER(hasAnyOperatorName);
   REGISTER_MATCHER(hasAnyParameter);
   REGISTER_MATCHER(hasAnyPlacementArg);
   REGISTER_MATCHER(hasAnySelector);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -380,6 +380,10 @@
   return hasAnySelectorMatcher(vectorFromRefs(NameRefs));
 }
 
+HasOpNameMatcher hasAnyOperatorNameFunc(ArrayRef NameRefs) {
+  return HasOpNameMatcher(vectorFromRefs(NameRefs));
+}
+
 HasNameMatcher::HasNameMatcher(std::vector N)
 : UseUnqualifiedMatch(std::all_of(
   N.begin(), N.end(),
@@ -854,6 +858,10 @@
 const internal::VariadicFunction, StringRef,
  internal::hasAnyNameFunc>
 hasAnyName = {};
+
+const internal::VariadicFunction
+hasAnyOperatorName = {};
 const internal::VariadicFunction, StringRef,
  internal::hasAnySelectorFunc>
 hasAnySelector = {};
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1858,6 +1858,50 @@
 llvm::Optional
 getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc,
const ASTContext &Context);
+
+/// Matches overloaded operators with a specific name.
+///
+/// The type argument ArgT is not used by this matcher but is used by
+/// PolymorphicMatcherWithParam1 and should be StringRef.
+template 
+class HasAnyOperatorNameMatcher : public SingleNodeMatcherInterface {
+  static_assert(std::is_same::value ||
+std::is_same::value,
+"unsupported class for matcher");
+  static_assert(std::is_same>::value,
+   

[PATCH] D75038: [ARM,MVE] Remove 64-bit variants of vbrsrq* intrinsics

2020-02-24 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG12fed51c0807: [ARM,MVE] Remove 64-bit variants of vbrsrq* 
intrinsics (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75038

Files:
  clang/include/clang/Basic/arm_mve.td


Index: clang/include/clang/Basic/arm_mve.td
===
--- clang/include/clang/Basic/arm_mve.td
+++ clang/include/clang/Basic/arm_mve.td
@@ -1310,7 +1310,7 @@
   }
 }
 
-let params = T.All in {
+let params = T.Usual in {
 let pnt = PNT_NType in
 def vbrsrq_n: Intrinsic $a, $b)>;


Index: clang/include/clang/Basic/arm_mve.td
===
--- clang/include/clang/Basic/arm_mve.td
+++ clang/include/clang/Basic/arm_mve.td
@@ -1310,7 +1310,7 @@
   }
 }
 
-let params = T.All in {
+let params = T.Usual in {
 let pnt = PNT_NType in
 def vbrsrq_n: Intrinsic $a, $b)>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74643: [Parse] Fix `TryParsePtrOperatorSeq`.

2020-02-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

Thank you for the new tests and drive-by fix for `_Atomic`! LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74643



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


[PATCH] D75041: [WIP][clang-tidy] Approximate implicit conversion issues for the 'cppcoreguidelines-avoid-adjacent-arguments-of-same-type' check

2020-02-24 Thread Whisperity via Phabricator via cfe-commits
whisperity created this revision.
whisperity added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, martong, gamesh411, Szelethus, dkrupp, 
rnkovacs, kbarton, xazax.hun, nemanjai.
Herald added a project: clang.
whisperity added a parent revision: D69560: [clang-tidy] Add 
'cppcoreguidelines-avoid-adjacent-arguments-of-same-type' check.
Herald added a subscriber: wuzish.
whisperity planned changes to this revision.

This patch adds an optional modelling of implicit conversions to the 
`cppcoreguidelines-avoid-adjacent-arguments-of-same-type` check. This will 
allow also diagnosing functions such as `void f(int i, double d);` to have a 
mix-up chance, i.e. `f(double_var, int_var);`. User-defined conversions are 
also attempted and supported.

Unfortunately, there isn't a sensible way (at least I found none) to ask `Sema` 
at //"frontend time"// whether or not the two args could be implicitly 
converted between one another, as we do not have the `Sema` instance anymore. 
Hence there is extra work done here to model the conversions - we believe the 
check's code under-approximates the real issue, but the current findings are 
valid semantically.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75041

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AdjacentArgumentsOfSameTypeCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AdjacentArgumentsOfSameTypeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-adjacent-arguments-of-same-type.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type-cvr-on.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type-default.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type-implicits.c
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type-implicits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type-verbose.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type.c

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type.c
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type.c
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type.c
@@ -2,7 +2,8 @@
 // RUN:   cppcoreguidelines-avoid-adjacent-arguments-of-same-type %t \
 // RUN:   -config='{CheckOptions: [ \
 // RUN: {key: cppcoreguidelines-avoid-adjacent-arguments-of-same-type.MinimumLength, value: 2}, \
-// RUN: {key: cppcoreguidelines-avoid-adjacent-arguments-of-same-type.CVRMixPossible, value: 1} \
+// RUN: {key: cppcoreguidelines-avoid-adjacent-arguments-of-same-type.CVRMixPossible, value: 1}, \
+// RUN: {key: cppcoreguidelines-avoid-adjacent-arguments-of-same-type.ImplicitConversion, value: 0} \
 // RUN:   ]}' --
 
 struct T {};
@@ -29,3 +30,6 @@
 int equals2(S l, S r) { return l.x == r.x; }
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 2 adjacent arguments for 'equals2' of similar type ('S') are
 // CHECK-MESSAGES: :[[@LINE-2]]:20: note: last argument in the adjacent range
+
+void ptrs(int *i, long *l) {}
+// NO-WARN: Mixing fundamentals' pointers is diagnosed by compiler warnings.
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type-verbose.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type-verbose.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-adjacent-arguments-of-same-type-verbose.cpp
@@ -2,7 +2,8 @@
 // RUN:   cppcoreguidelines-avoid-adjacent-arguments-of-same-type %t \
 // RUN:   -config='{CheckOptions: [ \
 // RUN: {key: cppcoreguidelines-avoid-adjacent-arguments-of-same-type.MinimumLength, value: 2}, \
-// RUN: {key: cppcoreguidelines-avoid-adjacent-arguments-of-same-type.CVRMixPossible, value: 1} \
+// RUN: {key: cppcoreguidelines-avoid-adjacent-arguments-of-same-type.CVRMixPossible, value: 1}, \
+// RUN: {key: cppcoreguidelines-avoid-adjacent-arguments-of-same-type.ImplicitConversion, value: 0} \
 // RUN:   ]}' --
 
 void library(void *vp, void *vp2, void *vp3, int n, int m);
@@ -124,6 +125,18 @@
 // CHECK-MESSAGES: :[[@LINE-3]]:32: note: after resolving type aliases, type of argument 'p1' is 'int *'
 // CHECK-MESSAGES: :[[@LINE-4]]:40: note: after resolving type aliases, type of argument 'p2' is 'int *'
 
+void typedef_and_realtype_ptr_const(int *p1, const I1 *p2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 2 adjacent arguments for 'typedef_

[clang] bd5b220 - Fix TryParsePtrOperatorSeq.

2020-02-24 Thread Aaron Ballman via cfe-commits

Author: Michele Scandale
Date: 2020-02-24T08:08:47-05:00
New Revision: bd5b22070b6984d89c13b6cf38c3e54fc98ce291

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

LOG: Fix TryParsePtrOperatorSeq.

The syntax rules for ptr-operator allow attributes after *, &,
&&, therefore we should be able to parse the following:

void fn() {
void (*[[attr]] x)() = &fn;
void (&[[attr]] y)() = fn;
void (&&[[attr]] z)() = fn;
}
However the current logic in TryParsePtrOperatorSeq does not consider
the presence of attributes leading to unexpected parsing errors.

Moreover we should also consider _Atomic a possible qualifier that can
appear after the sequence of attribute specifiers.

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseTentative.cpp
clang/test/CXX/dcl.decl/p4-0x.cpp
clang/test/Parser/cxx-ambig-decl-expr.cpp
clang/test/Parser/cxx-attributes.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 879c7fdf682d..8802bf9bb90a 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2442,6 +2442,10 @@ class Parser : public CodeCompletionHandler {
   TPResult TryParseBracketDeclarator();
   TPResult TryConsumeDeclarationSpecifier();
 
+  /// Try to skip a possibly empty sequence of 'attribute-specifier's without
+  /// full validation of the syntactic structure of attributes.
+  bool TrySkipAttributes();
+
 public:
   TypeResult ParseTypeName(SourceRange *Range = nullptr,
DeclaratorContext Context

diff  --git a/clang/lib/Parse/ParseTentative.cpp 
b/clang/lib/Parse/ParseTentative.cpp
index ad0a15b0c8a6..75cc7c2912b5 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -186,21 +186,8 @@ Parser::TPResult Parser::TryConsumeDeclarationSpecifier() {
 ConsumeToken();
 
 // Skip attributes.
-while (Tok.isOneOf(tok::l_square, tok::kw___attribute, tok::kw___declspec,
-   tok::kw_alignas)) {
-  if (Tok.is(tok::l_square)) {
-ConsumeBracket();
-if (!SkipUntil(tok::r_square))
-  return TPResult::Error;
-  } else {
-ConsumeToken();
-if (Tok.isNot(tok::l_paren))
-  return TPResult::Error;
-ConsumeParen();
-if (!SkipUntil(tok::r_paren))
-  return TPResult::Error;
-  }
-}
+if (!TrySkipAttributes())
+  return TPResult::Error;
 
 if (TryAnnotateOptionalCXXScopeToken())
   return TPResult::Error;
@@ -781,6 +768,32 @@ Parser::isCXX11AttributeSpecifier(bool Disambiguate,
   return CAK_NotAttributeSpecifier;
 }
 
+bool Parser::TrySkipAttributes() {
+  while (Tok.isOneOf(tok::l_square, tok::kw___attribute, tok::kw___declspec,
+ tok::kw_alignas)) {
+if (Tok.is(tok::l_square)) {
+  ConsumeBracket();
+  if (Tok.isNot(tok::l_square))
+return false;
+  ConsumeBracket();
+  if (!SkipUntil(tok::r_square) || Tok.isNot(tok::r_square))
+return false;
+  // Note that explicitly checking for `[[` and `]]` allows to fail as
+  // expected in the case of the Objective-C message send syntax.
+  ConsumeBracket();
+} else {
+  ConsumeToken();
+  if (Tok.isNot(tok::l_paren))
+return false;
+  ConsumeParen();
+  if (!SkipUntil(tok::r_paren))
+return false;
+}
+  }
+
+  return true;
+}
+
 Parser::TPResult Parser::TryParsePtrOperatorSeq() {
   while (true) {
 if (TryAnnotateOptionalCXXScopeToken(true))
@@ -790,9 +803,14 @@ Parser::TPResult Parser::TryParsePtrOperatorSeq() {
 (Tok.is(tok::annot_cxxscope) && NextToken().is(tok::star))) {
   // ptr-operator
   ConsumeAnyToken();
+
+  // Skip attributes.
+  if (!TrySkipAttributes())
+return TPResult::Error;
+
   while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict,
  tok::kw__Nonnull, tok::kw__Nullable,
- tok::kw__Null_unspecified))
+ tok::kw__Null_unspecified, tok::kw__Atomic))
 ConsumeToken();
 } else {
   return TPResult::True;

diff  --git a/clang/test/CXX/dcl.decl/p4-0x.cpp 
b/clang/test/CXX/dcl.decl/p4-0x.cpp
index 35177a038697..3a7b21568044 100644
--- a/clang/test/CXX/dcl.decl/p4-0x.cpp
+++ b/clang/test/CXX/dcl.decl/p4-0x.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 struct X {
   void f() &;
@@ -7,3 +6,15 @@ struct X {
 };
 
 void (X::*pmf)() & = &X::f;
+
+void fn() {
+  void (*[[attr]] fn_ptr)() = &fn; // expected-warning{{unknown attribute 
'attr' ignored}}
+  void (*[[attrA]] *[[attrB]] fn_ptr_ptr)() = &fn_ptr; // 
expected-warn

[PATCH] D74643: [Parse] Fix `TryParsePtrOperatorSeq`.

2020-02-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the patch -- I've commit on your behalf in 
bd5b22070b6984d89c13b6cf38c3e54fc98ce291 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74643



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


[PATCH] D75044: [AArch64] __builtin_extract_return_addr for PAuth.

2020-02-24 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss created this revision.
danielkiss added reviewers: ostannard, asl.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.

This change adds the support for __builtin_extract_return_addr
for ARMv8.3A Pointer Authentications.
Location of the authentication code in the pointer depends on
the system configuration, therefor a dedicated instruction is used for
effectively removing the authentication code without
authenticating the pointer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75044

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/arm64-extractreturnaddress.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/test/CodeGen/AArch64/aarch64-extractreturnaddress.ll

Index: llvm/test/CodeGen/AArch64/aarch64-extractreturnaddress.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/aarch64-extractreturnaddress.ll
@@ -0,0 +1,29 @@
+; RUN: llc < %s -mtriple=arm64-eabi -asm-verbose=false -mattr=v8.2a | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-eabi -asm-verbose=false -mattr=v8.3a | FileCheck %s --check-prefix=CHECKV83
+
+; Armv8.3-A Pointer Authetication requires a special intsruction to strip the
+; pointer authentication code from the pointer.
+; The XPACLRI instruction assembles to a hint-space instruction before Armv8.3-A
+; therefore this instruction can be safely used for any pre Armv8.3-A architectures.
+; On Armv8.3-A and onwards XPACI is available so use that instead.
+
+define i8* @era0(i8* %x) nounwind readnone #0 {
+entry:
+; CHECK-LABEL: era0:
+; CHECK:  hint #25
+; CHECK-NEXT: str x30, [sp, #-16]!
+; CHECK-NEXT: mov x30, x0
+; CHECK-NEXT: hint #7
+; CHECK-NEXT: mov x0, x30
+; CHECK-NEXT: ldr x30, [sp], #16
+; CHECK-NEXT: hint #29
+; CHECK-NEXT: ret
+; CHECKV83:   paciasp
+; CHECKV83-NEXT:  xpaci   x0
+; CHECKV83-NEXT:  retaa
+  %0 = tail call i8* @llvm.extractreturnaddress(i8* %x)
+  ret i8* %0
+}
+attributes #0 = { "sign-return-address"="all" }
+
+declare i8* @llvm.extractreturnaddress(i8*) nounwind readnone
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.h
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -738,6 +738,7 @@
   SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerSPONENTRY(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
+  SDValue LowerEXTRACTRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -3249,6 +3249,8 @@
 return LowerSPONENTRY(Op, DAG);
   case ISD::RETURNADDR:
 return LowerRETURNADDR(Op, DAG);
+  case ISD::EXTRACTRETURNADDR:
+return LowerEXTRACTRETURNADDR(Op, DAG);
   case ISD::ADDROFRETURNADDR:
 return LowerADDROFRETURNADDR(Op, DAG);
   case ISD::INSERT_VECTOR_ELT:
@@ -5953,6 +5955,27 @@
   return DAG.getCopyFromReg(DAG.getEntryNode(), DL, Reg, VT);
 }
 
+SDValue AArch64TargetLowering::LowerEXTRACTRETURNADDR(SDValue Op,
+  SelectionDAG &DAG) const {
+  SDLoc DL(Op);
+  EVT VT = Op.getValueType();
+
+  // The XPACLRI instruction assembles to a hint-space instruction before
+  // Armv8.3-A therefore this instruction can be safely used for any pre
+  // Armv8.3-A architectures. On Armv8.3-A and onwards XPACI is available so use
+  // that instead.
+  if (Subtarget->hasV8_3aOps()) {
+SDNode *St = DAG.getMachineNode(AArch64::XPACI, DL, VT, Op.getOperand(0));
+return SDValue(St, 0);
+  } else {
+// XPACLRI operates on LR therefore we must move the operand accordingly.
+SDValue Reg =
+DAG.getCopyToReg(DAG.getEntryNode(), DL, AArch64::LR, Op.getOperand(0));
+SDNode *St = DAG.getMachineNode(AArch64::XPACLRI, DL, VT, Reg);
+return SDValue(St, 0);
+  }
+}
+
 /// LowerShiftRightParts - Lower SRA_PARTS, which returns two
 /// i64 values and take a 2 x i64 value to shift plus a shift amount.
 SDValue AArch64TargetLowering::LowerShiftRightParts(SDValue Op,
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
=

[PATCH] D75045: [analyzer] Improved check of `fgetc` in StreamChecker.

2020-02-24 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, martong, Charusso, gamesh411, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: clang.

A warning is produced if the `getc` call fails (returns EOF) and
the next called stream function is not `feof` and `ferror`
(both are needed).
This check is inspired by CERT rule FIO34-C "Distinguish between characters 
read from a file and EOF or WEOF".
https://wiki.sei.cmu.edu/confluence/display/c/FIO34-C.+Distinguish+between+characters+read+from+a+file+and+EOF+or+WEOF

Other similar functions (and wide versions) are to be added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75045

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -6,11 +6,13 @@
 #define SEEK_SET	0	/* Seek from beginning of file.  */
 #define SEEK_CUR	1	/* Seek from current position.  */
 #define SEEK_END	2	/* Seek from end of file.  */
+#define EOF (-1)
 extern FILE *fopen(const char *path, const char *mode);
 extern FILE *tmpfile(void);
 extern int fclose(FILE *fp);
 extern size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
 extern size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
+extern int fgetc(FILE *stream);
 extern int fseek (FILE *__stream, long int __off, int __whence);
 extern long int ftell (FILE *__stream);
 extern void rewind (FILE *__stream);
@@ -176,3 +178,74 @@
 fclose(f1);
   }
 }
+
+void check_fgetc_error() {
+  FILE *fp = fopen("foo.c", "r");
+  if (fp) {
+int C;
+fpos_t pos;
+C = fgetc(fp);
+fread(0, 0, 0, fp); // expected-warning {{Should call}}
+fread(0, 0, 0, fp);
+C = fgetc(fp);
+fwrite(0, 0, 0, fp); // expected-warning {{Should call}}
+C = fgetc(fp);
+fseek(fp, 1, SEEK_SET); // expected-warning {{Should call}}
+C = fgetc(fp);
+ftell(fp); // expected-warning {{Should call}}
+C = fgetc(fp);
+rewind(fp); // expected-warning {{Should call}}
+C = fgetc(fp);
+fgetpos(fp, &pos); // expected-warning {{Should call}}
+C = fgetc(fp);
+fsetpos(fp, 0); // expected-warning {{Should call}}
+C = fgetc(fp);
+clearerr(fp); // expected-warning {{Should call}}
+C = fgetc(fp);
+C = fgetc(fp);// expected-warning {{Should call}}
+fp = freopen(0, "w", fp); // expected-warning {{Should call}}
+C = fgetc(fp);
+fclose(fp); // expected-warning {{Should call}}
+  }
+}
+
+void check_fgetc_error1() {
+  FILE *fp = fopen("foo.c", "r");
+  if (fp) {
+int C;
+C = fgetc(fp);
+feof(fp);
+fclose(fp); // expected-warning {{Should call}}
+  }
+  fp = fopen("foo.c", "r");
+  if (fp) {
+int C;
+C = fgetc(fp);
+ferror(fp);
+fclose(fp); // expected-warning {{Should call}}
+  }
+}
+
+void check_fgetc_noerror() {
+  FILE *fp = fopen("foo.c", "r");
+  if (fp) {
+int C;
+C = fgetc(fp);
+feof(fp);
+ferror(fp);
+fclose(fp);
+  }
+}
+
+void check_fgetc_checked() {
+  FILE *fp = fopen("foo.c", "r");
+  if (fp) {
+int C;
+C = fgetc(fp);
+if (C == EOF) {
+  feof(fp);
+  ferror(fp);
+}
+fclose(fp);
+  }
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -16,6 +16,7 @@
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
@@ -29,15 +30,23 @@
 
 struct StreamState {
   enum Kind { Opened, Closed, OpenFailed, Escaped } K;
+  bool ShouldCallFeof{false};
+  bool ShouldCallFerror{false};
 
-  StreamState(Kind k) : K(k) {}
+  StreamState(Kind k, bool Feof, bool Ferror)
+  : K(k), ShouldCallFeof{Feof}, ShouldCallFerror{Ferror} {}
+  StreamState(Kind k, bool MakeError = false)
+  : K(k), ShouldCallFeof{MakeError}, ShouldCallFerror{MakeError} {}
 
   bool isOpened() const { return K == Opened; }
   bool isClosed() const { return K == Closed; }
   //bool isOpenFailed() const { return K == OpenFailed; }
   //bool isEscaped() const { return K == Escaped; }
 
-  bool operator==(const StreamState &X) const { return K == X.K; }
+  bool operator==(const StreamState &X) const {
+return K == X.K && ShouldCallFeof == X.ShouldCallFeof &&
+   ShouldCall

[PATCH] D75040: [ASTMatchers] Adds a matcher called `hasAnyOperatorName`

2020-02-24 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1870
+std::is_same::value,
+"unsupported class for matcher");
+  static_assert(std::is_same>::value,

Consider enhancing the message to say what the expected types are.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75040



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


[PATCH] D75040: [ASTMatchers] Adds a matcher called `hasAnyOperatorName`

2020-02-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM




Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1880-1884
+for (const std::string &Name : Names) {
+  if (Name == OpName)
+return true;
+}
+return false;

Can we use `llvm::find()` instead of a manual loop?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75040



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


[PATCH] D75040: [ASTMatchers] Adds a matcher called `hasAnyOperatorName`

2020-02-24 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4772
+///
+/// FIXME: Tweak to improve docs generated
+extern const internal::VariadicFunctionhttps://reviews.llvm.org/D75040/new/

https://reviews.llvm.org/D75040



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


[PATCH] D74720: [ASTImporter] Improved variable template redecl chain handling.

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74720



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


[PATCH] D71018: [ASTImporter] Improved import of TypeSourceInfo (TypeLoc)

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@shafik
Ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018



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


[PATCH] D75046: [docs] dump_ast_matchers strips internal::(Bindable)?Matcher from Result_type

2020-02-24 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: joerg, gribozavr2, aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove `internal::Matcher` and `internal::BindableMatcher` from Result Type 
when dumping AST Matchers


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75046

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/tools/dump_ast_matchers.py
  clang/include/clang/ASTMatchers/ASTMatchers.h

Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -307,7 +307,7 @@
 ///
 /// FIXME: Change to be a polymorphic matcher that works on any syntactic
 /// node. There's nothing `Stmt`-specific about it.
-AST_MATCHER_P(clang::Stmt, isExpandedFromMacro, llvm::StringRef, MacroName) {
+AST_MATCHER_P(Stmt, isExpandedFromMacro, llvm::StringRef, MacroName) {
   // Verifies that the statement' beginning and ending are both expanded from
   // the same instance of the given macro.
   auto& Context = Finder->getASTContext();
Index: clang/docs/tools/dump_ast_matchers.py
===
--- clang/docs/tools/dump_ast_matchers.py
+++ clang/docs/tools/dump_ast_matchers.py
@@ -103,6 +103,11 @@
   args = re.sub(r'(^|\s)M\d?(\s)', r'\1Matcher<*>\2', args)
   return args
 
+def unify_type(result_type):
+  """Gets rid of anything the user doesn't care about in the type name."""
+  result_type = re.sub(r'^internal::(Bindable)?Matcher<([a-zA-Z_][a-zA-Z0-9_]*)>$', r'\2', result_type)
+  return result_type
+
 def add_matcher(result_type, name, args, comment, is_dyncast=False):
   """Adds a matcher to one of our categories."""
   if name == 'id':
@@ -111,6 +116,7 @@
   matcher_id = '%s%d' % (name, ids[name])
   ids[name] += 1
   args = unify_arguments(args)
+  result_type = unify_type(result_type)
   matcher_html = TD_TEMPLATE % {
 'result': esc('Matcher<%s>' % result_type),
 'name': name,
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -2948,6 +2948,19 @@
 
 
 
+MatcherDecl>isInstantiated
+Matches declarations that are template instantiations or are inside
+template instantiations.
+
+Given
+  template void A(T t) { T i; }
+  A(0);
+  A(0U);
+functionDecl(isInstantiated())
+  matches 'A(int) {...};' and 'A(unsigned) {...}'.
+
+
+
 MatcherDecl>isPrivate
 Matches private C++ declarations.
 
@@ -3516,6 +3529,16 @@
 
 
 
+MatcherNamedDecl>hasAnyNameStringRef, ..., StringRef
+Matches NamedDecl nodes that have any of the specified names.
+
+This matcher is only provided as a performance optimization of hasName.
+hasAnyName(a, b, c)
+ is equivalent to, but faster than
+anyOf(hasName(a), hasName(b), hasName(c))
+
+
+
 MatcherNamedDecl>hasExternalFormalLinkage
 Matches a declaration that has external formal linkage.
 
@@ -3679,6 +3702,17 @@
 
 
 
+MatcherObjCMessageExpr>hasAnySelectorStringRef, ..., StringRef
+Matches when at least one of the supplied string equals to the
+Selector.getAsString()
+
+ matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
+ matches both of the expressions below:
+[myObj methodA:argA];
+[myObj methodB:argB];
+
+
+
 MatcherObjCMessageExpr>hasKeywordSelector
 Matches when the selector is a keyword selector
 
@@ -4015,6 +4049,17 @@
 
 
 
+MatcherStmt>isExpandedFromMacrollvm::StringRef MacroName
+Matches statements that are (transitively) expanded from the named macro.
+Does not match if only part of the statement is expanded from that macro or
+if different parts of the the statement are expanded from different
+appearances of the macro.
+
+FIXME: Change to be a polymorphic matcher that works on any syntactic
+node. There's nothing `Stmt`-specific about it.
+
+
+
 MatcherStmt>isExpansionInFileMatchingstd::string RegExp
 Matches AST nodes that were expanded within files whose name is
 partially matching a given regex.
@@ -4058,6 +4103,22 @@
 
 
 
+MatcherStmt>isInTemplateInstantiation
+Matches statements inside of a template instantiation.
+
+Given
+  int j;
+  template void A(T t) { T i; j += 42;}
+  A(0);
+  A(0U);
+declStmt(isInTemplateInstantiation())
+  matches 'in

[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-02-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:10293
Tab));
-  EXPECT_EQ("/*\n"
-"\t  a\t\tcomment\n"

Sorry this isn't clear to be which test this is a duplicate of, as this is an 
example where there are tabs in the comment and trailing tabs


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

https://reviews.llvm.org/D75034



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


[PATCH] D75040: [ASTMatchers] Adds a matcher called `hasAnyOperatorName`

2020-02-24 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 246190.
njames93 marked an inline comment as done.
njames93 edited the summary of this revision.
njames93 added a comment.

- Address nits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75040

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1123,6 +1123,19 @@
   EXPECT_TRUE(notMatches("void x() { true && false; }", OperatorOr));
 }
 
+TEST(MatchBinaryOperator, HasAnyOperatorName) {
+  StatementMatcher Matcher =
+  binaryOperator(hasAnyOperatorName("+", "-", "*", "/"));
+
+  EXPECT_TRUE(matches("int x(int I) { return I + 2; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return I - 2; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return I * 2; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return I / 2; }", Matcher));
+  EXPECT_TRUE(notMatches("int x(int I) { return I % 2; }", Matcher));
+  // Ensure '+= isn't mistaken.
+  EXPECT_TRUE(notMatches("void x(int &I) { I += 1; }", Matcher));
+}
+
 TEST(MatchBinaryOperator, HasLHSAndHasRHS) {
   StatementMatcher OperatorTrueFalse =
 binaryOperator(hasLHS(cxxBoolLiteral(equals(true))),
@@ -1255,6 +1268,18 @@
   EXPECT_TRUE(notMatches("void x() { true; } ", OperatorNot));
 }
 
+TEST(MatchUnaryOperator, HasAnyOperatorName) {
+  StatementMatcher Matcher = unaryOperator(hasAnyOperatorName("-", "*", "++"));
+
+  EXPECT_TRUE(matches("int x(int *I) { return *I; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return -I; }", Matcher));
+  EXPECT_TRUE(matches("void x(int &I) { I++; }", Matcher));
+  EXPECT_TRUE(matches("void x(int &I) { ++I; }", Matcher));
+  EXPECT_TRUE(notMatches("void x(int &I) { I--; }", Matcher));
+  EXPECT_TRUE(notMatches("void x(int &I) { --I; }", Matcher));
+  EXPECT_TRUE(notMatches("int *x(int &I) { return &I; }", Matcher));
+}
+
 TEST(MatchUnaryOperator, HasUnaryOperand) {
   StatementMatcher OperatorOnFalse =
 unaryOperator(hasUnaryOperand(cxxBoolLiteral(equals(false;
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -243,6 +243,7 @@
   REGISTER_MATCHER(hasAnyConstructorInitializer);
   REGISTER_MATCHER(hasAnyDeclaration);
   REGISTER_MATCHER(hasAnyName);
+  REGISTER_MATCHER(hasAnyOperatorName);
   REGISTER_MATCHER(hasAnyParameter);
   REGISTER_MATCHER(hasAnyPlacementArg);
   REGISTER_MATCHER(hasAnySelector);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -380,6 +380,10 @@
   return hasAnySelectorMatcher(vectorFromRefs(NameRefs));
 }
 
+HasOpNameMatcher hasAnyOperatorNameFunc(ArrayRef NameRefs) {
+  return HasOpNameMatcher(vectorFromRefs(NameRefs));
+}
+
 HasNameMatcher::HasNameMatcher(std::vector N)
 : UseUnqualifiedMatch(std::all_of(
   N.begin(), N.end(),
@@ -854,6 +858,10 @@
 const internal::VariadicFunction, StringRef,
  internal::hasAnyNameFunc>
 hasAnyName = {};
+
+const internal::VariadicFunction
+hasAnyOperatorName = {};
 const internal::VariadicFunction, StringRef,
  internal::hasAnySelectorFunc>
 hasAnySelector = {};
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1858,6 +1858,47 @@
 llvm::Optional
 getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc,
const ASTContext &Context);
+
+/// Matches overloaded operators with a specific name.
+///
+/// The type argument ArgT is not used by this matcher but is used by
+/// PolymorphicMatcherWithParam1 and should be std::vector>.
+template >
+class HasAnyOperatorNameMatcher : public SingleNodeMatcherInterface {
+  static_assert(std::is_same::value ||
+std::is_same::value,
+"Matcher only supports `BinaryOperator` and `UnaryOperator`");
+  static_assert(std::is_same>::value,
+"Matcher ArgT must be std::vector");
+
+public:
+  explicit HasAnyOperatorNameMatcher(std::vector Names)
+  : SingleNodeMatcherInterface(), Names

[PATCH] D75040: [ASTMatchers] Adds a matcher called `hasAnyOperatorName`

2020-02-24 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1870
+std::is_same::value,
+"unsupported class for matcher");
+  static_assert(std::is_same>::value,

gribozavr2 wrote:
> Consider enhancing the message to say what the expected types are.
This is the reason c++17 removed the need for static_assert messages, the 
message isn't needed as you can figure the error from the predicate



Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1880-1884
+for (const std::string &Name : Names) {
+  if (Name == OpName)
+return true;
+}
+return false;

aaron.ballman wrote:
> Can we use `llvm::find()` instead of a manual loop?
`llvm::is_contained` would be better, but they involve creating temporaries, 
`llvm::any_of` does it best I think


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75040



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


[PATCH] D75047: Add Control Flow Guard in Clang release notes.

2020-02-24 Thread Andrew Paverd via Phabricator via cfe-commits
ajpaverd created this revision.
ajpaverd added a reviewer: hans.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75047

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -204,6 +204,11 @@
 - Fixed handling of TLS variables that are shared between object files
   in MinGW environments
 
+- The ``-cfguard`` flag now emits Windows Control Flow Guard checks on indirect
+  function calls. The previous behavior is still available with the 
+  ``-cfguard-nochecks`` flag. These checks can be disabled for specific 
+  functions using the new ``__declspec(guard(nocf))`` modifier.
+
 C Language Changes in Clang
 ---
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -204,6 +204,11 @@
 - Fixed handling of TLS variables that are shared between object files
   in MinGW environments
 
+- The ``-cfguard`` flag now emits Windows Control Flow Guard checks on indirect
+  function calls. The previous behavior is still available with the 
+  ``-cfguard-nochecks`` flag. These checks can be disabled for specific 
+  functions using the new ``__declspec(guard(nocf))`` modifier.
+
 C Language Changes in Clang
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-02-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added subscribers: djasper, klimek.
MyDeveloperDay added a comment.

> Is this intentional, or is it an oversight?

This is the key question, which I'm not sure how we can answer without the help 
of the original authors @djasper and @klimek

For example I can't understand with the example below if the TabWith is 8 why 
are you putting 13 spaces in, rather than the original test which had 1 tab 
(assuming 8 characters) and 5 spaces? (to make up 13)

Could you explain why this is the correct change for this example why its 
correct to put 13 spaces? (is this not continuation or indentation?)

  Tab.UseTab = FormatStyle::UT_ForContinuationAndIndentation;
  Tab.TabWidth = 8;
  Tab.IndentWidth = 8;
  verifyFormat("class X {\n"
   "\tvoid f() {\n"
   "\t\tsomeFunction(parameter1,\n"
   "\t\t.parameter2);\n"
   "\t}\n"
   "};",
   Tab);


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

https://reviews.llvm.org/D75034



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


[PATCH] D74941: [OpenMP] `omp begin/end declare variant` - part 1, parsing

2020-02-24 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a subscriber: gregrodgers.
JonChesterfield added a comment.

Thanks! Splitting this out of D71179 , which I 
think ultimately reached consensus, makes the diff much easier to read.

Subscribing Greg, as I think this is a path to removing a lot of downstream 
complexity in math.h handling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74941



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


[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-02-24 Thread Maximilian Fickert via Phabricator via cfe-commits
fickert marked an inline comment as done.
fickert added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:10293
Tab));
-  EXPECT_EQ("/*\n"
-"\t  a\t\tcomment\n"

MyDeveloperDay wrote:
> Sorry this isn't clear to be which test this is a duplicate of, as this is an 
> example where there are tabs in the comment and trailing tabs
This test case is identical to the one in line 10182-10190. There are several 
test cases that appear multiple times, but usually with changes to the 
formatting settings in between. This is not the case for these two test cases 
(no changes in between), so this one seems to be obsolete.


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

https://reviews.llvm.org/D75034



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


[PATCH] D75040: [ASTMatchers] Adds a matcher called `hasAnyOperatorName`

2020-02-24 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4772
+///
+/// FIXME: Tweak to improve docs generated
+extern const internal::VariadicFunction Any specific things you would like to improve? The fixme is rather vague.
This is what comes up in the ASTMatchersReference docs. 
```
Matcher hasAnyOperatorName  StringRef, ..., 
StringRef```
I would like it to have 
```
Matcher  hasAnyOperatorName StringRef, ..., StringRef
...
Matcher  hasAnyOperatorName  StringRef, ..., StringRef```
However how VariadicFunction is matched in the dumper won't support that yet. 
And If you want to support it properly regex wouldn't work, instead you'd need 
a parser


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75040



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:418
+if (FailureSt && !SuccessSt) {
+  C.addTransition(FailureSt);
+  if (ExplodedNode *N = C.generateErrorNode(FailureSt))

balazske wrote:
> Is this `addTransition` needed? It would be OK to call `generateErrorNode` 
> with `State`. Even if not, adding the transition before should not be needed?
Yes, you are right it is superfluous, I removed it.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:688
   // locale-specific return values.
   .Case({ArgumentCondition(0U, WithinRange, {{128, 
UCharMax}})})
   .Case({ArgumentCondition(0U, OutOfRange,

balazske wrote:
> Why is this `{128, UCharMax}` here and at the next entry needed?
This is the local specific range , [128, 255]. There are characters like `ä` 
which we don't know if they are treated as an alphanumerical character or not. 
We can't really tell how a specific libc implementation classifies them. On the 
other hand, with English letters we can state the classes confidently.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:696
+  .ArgConstraint(ArgumentCondition(
+  0U, WithinRange, {{EOFv, EOFv}, {0, UCharMax}}))},
   },

balazske wrote:
> Is this `ArgConstraint` intentionally added only to `isalnum`?
> 
Yes, I wanted to create first the infrastructure and then later to add all 
these constraints to the rest of the summaries with new tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D74734: [AArch64][SVE] Add the SVE dupq_lane intrinsic

2020-02-24 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kmclaughlin marked an inline comment as done.
Closed by commit rGf87f23c81cae: [AArch64][SVE] Add the SVE dupq_lane intrinsic 
(authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D74734?vs=245012&id=246194#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74734

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -297,6 +297,179 @@
 }
 
 ;
+; DUPQ
+;
+
+define  @dupq_i8( %a) {
+; CHECK-LABEL: dupq_i8:
+; CHECK: mov z0.q, q0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %a, i64 0)
+  ret  %out
+}
+
+define  @dupq_i16( %a) {
+; CHECK-LABEL: dupq_i16:
+; CHECK: mov z0.q, z0.q[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %a, i64 1)
+  ret  %out
+}
+
+define  @dupq_i32( %a) {
+; CHECK-LABEL: dupq_i32:
+; CHECK: mov z0.q, z0.q[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv4i32( %a, i64 2)
+  ret  %out
+}
+
+define  @dupq_i64( %a) {
+; CHECK-LABEL: dupq_i64:
+; CHECK: mov z0.q, z0.q[3]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv2i64( %a, i64 3)
+  ret  %out
+}
+
+define  @dupq_f16( %a) {
+; CHECK-LABEL: dupq_f16:
+; CHECK: mov z0.q, q0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv8f16( %a, i64 0)
+  ret  %out
+}
+
+define  @dupq_f32( %a) {
+; CHECK-LABEL: dupq_f32:
+; CHECK: mov z0.q, z0.q[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv4f32( %a, i64 1)
+  ret  %out
+}
+
+define  @dupq_f64( %a) {
+; CHECK-LABEL: dupq_f64:
+; CHECK: mov z0.q, z0.q[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv2f64( %a, i64 2)
+  ret  %out
+}
+
+;
+; DUPQ_LANE
+;
+
+define  @dupq_lane_i8( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i8:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK-NEXT: tbl   z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_i16( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i16:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK: tbl z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_i32( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i32:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK: tbl z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv4i32( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_i64( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i64:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK: tbl z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv2i64( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_f16( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_f16:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK: tbl z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv8f16( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_f32( %a, i64 %idx) {
+; CHECK-

[PATCH] D74734: [AArch64][SVE] Add the SVE dupq_lane intrinsic

2020-02-24 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin marked 4 inline comments as done.
kmclaughlin added a comment.

Thanks for taking a look at this, @sdesmalen!




Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:7496
+  auto CIdx = dyn_cast(Idx128);
+  if (CIdx && (CIdx->getZExtValue() <= 3)) {
+auto CI = DAG.getTargetConstant(CIdx->getZExtValue(), DL, MVT::i64);

sdesmalen wrote:
> nit: can you replace `auto` in these cases with SDValue? (which I think this 
> is?)
Replaced other cases of auto here with SDValue or SDNode


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74734



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 246193.
martong marked 7 inline comments as done.
martong added a comment.

- Use StringRef for Msg
- Remove superfluous addTransition


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c


Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -37,10 +37,8 @@
   y = 0;
   clang_analyzer_eval(EOF <= x && x <= 255); // expected-warning{{TRUE}}
 
-  if (x > 255) { // This path is no longer 
feasible.
-ret = isalnum(x);
+  if (x > 255) // This path is no longer feasible.
 ret = x / y; // No warning here
-  }
 
   ret = x / y; // expected-warning{{Division by zero}}
 }
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -404,7 +404,7 @@
 if (!ChecksEnabled[CK_StdCLibraryFunctionArgsChecker])
   return;
 // FIXME Add detailed diagnostic.
-std::string Msg = "Function argument constraint is not satisfied";
+StringRef Msg = "Function argument constraint is not satisfied";
 auto R = std::make_unique(BT, Msg, N);
 bugreporter::trackExpressionValue(N, Call.getArgExpr(0), *R);
 C.emitReport(std::move(R));
@@ -415,8 +415,7 @@
 ProgramStateRef FailureSt = VR.negate().apply(State, Call, Summary);
 // The argument constraint is not satisfied.
 if (FailureSt && !SuccessSt) {
-  C.addTransition(FailureSt);
-  if (ExplodedNode *N = C.generateErrorNode(FailureSt))
+  if (ExplodedNode *N = C.generateErrorNode(State))
 Report(N);
   break;
 } else {


Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -37,10 +37,8 @@
   y = 0;
   clang_analyzer_eval(EOF <= x && x <= 255); // expected-warning{{TRUE}}
 
-  if (x > 255) { // This path is no longer feasible.
-ret = isalnum(x);
+  if (x > 255) // This path is no longer feasible.
 ret = x / y; // No warning here
-  }
 
   ret = x / y; // expected-warning{{Division by zero}}
 }
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -404,7 +404,7 @@
 if (!ChecksEnabled[CK_StdCLibraryFunctionArgsChecker])
   return;
 // FIXME Add detailed diagnostic.
-std::string Msg = "Function argument constraint is not satisfied";
+StringRef Msg = "Function argument constraint is not satisfied";
 auto R = std::make_unique(BT, Msg, N);
 bugreporter::trackExpressionValue(N, Call.getArgExpr(0), *R);
 C.emitReport(std::move(R));
@@ -415,8 +415,7 @@
 ProgramStateRef FailureSt = VR.negate().apply(State, Call, Summary);
 // The argument constraint is not satisfied.
 if (FailureSt && !SuccessSt) {
-  C.addTransition(FailureSt);
-  if (ExplodedNode *N = C.generateErrorNode(FailureSt))
+  if (ExplodedNode *N = C.generateErrorNode(State))
 Report(N);
   break;
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74463: [clang-tidy] Add new check avoid-adjacent-unrelated-parameters-of-the-same-type

2020-02-24 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal added a comment.

> - how do we either not warn on this by default or how does the user tell us 
> to not warn on it (without requiring them to jump through hoops like changing 
> the types of the arguments)?

-I'v used comments in the source code to tell the tool to ignore cases that I'v 
identified as false positives. That has worked without any issues for me and I 
wouldn't say it's a hassle. Is that no longer supported in clang tidy or was I 
using another tool and just projected that memory on clang-tidy?
I'm confident that clang-format atleast has a means of locally suppressing 
rules.

> I'd also want to see some data as to how often this check warns with true 
> positives over a large, real-world code base (like LLVM).

-I could do this. I agree it makes sense to look at actual data on how much 
this detects and how much is noise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74463



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


[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-02-24 Thread Maximilian Fickert via Phabricator via cfe-commits
fickert added a comment.

In D75034#1889107 , @MyDeveloperDay 
wrote:

> > Is this intentional, or is it an oversight?
>
> This is the key question, which I'm not sure how we can answer without the 
> help of the original authors @djasper and @klimek
>
> For example I can't understand with the example below if the TabWith is 8 why 
> are you putting 13 spaces in, rather than the original test which had 1 tab 
> (assuming 8 characters) and 5 spaces? (to make up 13)
>
> Could you explain why this is the correct change for this example why its 
> correct to put 13 spaces? (is this not continuation or indentation?)
>
>   Tab.UseTab = FormatStyle::UT_ForContinuationAndIndentation;
>   Tab.TabWidth = 8;
>   Tab.IndentWidth = 8;
>   verifyFormat("class X {\n"
>"\tvoid f() {\n"
>"\t\tsomeFunction(parameter1,\n"
>"\t\t.parameter2);\n"
>"\t}\n"
>"};",
>Tab);
>   


In this example, the first two tabs are for indentation, and the remaining 
whitespace before parameter2 is for alignment (not continuation) with 
parameter1. If tabs are used in the alignment, the formatted code will only 
look aligned with the correct tab width, whereas if the alignment is done with 
spaces, the code will look aligned with arbitrary tab width.

I believe this to be the expected behavior for 
`UT_ForContinuationAndIndentation`, and tabs should only be used for alignment 
with `UT_Always`, but I would also be happy about comments from the original 
authors.


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

https://reviews.llvm.org/D75034



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


[PATCH] D74463: [clang-tidy] Add new check avoid-adjacent-unrelated-parameters-of-the-same-type

2020-02-24 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal added a comment.

In D74463#1889157 , @vingeldal wrote:

> > - how do we either not warn on this by default or how does the user tell us 
> > to not warn on it (without requiring them to jump through hoops like 
> > changing the types of the arguments)?
>
> -I'v used comments in the source code to tell the tool to ignore cases that 
> I'v identified as false positives. That has worked without any issues for me 
> and I wouldn't say it's a hassle. Is that no longer supported in clang tidy 
> or was I using another tool and just projected that memory on clang-tidy?
>  I'm confident that clang-format atleast has a means of locally suppressing 
> rules.


Found what I was thinking of: "// 
NOLINT(cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type)"
Do you think this is too much jumping through hoops or would that suffice as a 
means to get rid of false positives?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74463



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


[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> Is really more kind of constraint needed than range constraint?

Yes, there are other constraints I am planning to implement:

- Size requirements E.g.: asctime_s(char *buf, rsize_t bufsz, const struct tm 
*time_ptr); `buf` size must be at least `bufsz`.
- Not-null
- Not-uninitalized
- Not-tainted

> A non-null can be represented as range constraint too.

Actually, to implement that we should have a branch in all `ValueRange::apply*` 
functions that handles `Loc` SVals. Unfortunately, a pointer cannot be handled 
as `NonLoc`, and the current Range based implementation handles `NonLoc`s only.

> The compare constraint is used only for the return value for which a special 
> `ReturnConstraint` can be used to handle the return value not like a normal 
> argument (and then the `Ret` special value is not needed).

The Compare constraint is already forced into a Range "concept" whereas it has 
nothing to do with ranges. By handling compare constraints separately, we 
attach a single responsibility to each constraint class, instead of having a 
monolithic god constraint class. Take a look at this coerced data 
representation that we have today in ValueRange:

  BinaryOperator::Opcode getOpcode() const {
assert(Kind == ComparesToArgument);
assert(Args.size() == 1);
BinaryOperator::Opcode Op =
static_cast(Args[0].first);
assert(BinaryOperator::isComparisonOp(Op) &&
   "Only comparison ops are supported for ComparesToArgument");
return Op;
  }

Subclasses are a good way to get rid of this not-so-intuitive structure and 
assertions.

> Or are there sometimes relations between arguments of a function?

I can't recall now a direct relation by heart.
But there could be more subtle indirect relations, see the size requirements 
above. (Thought I'd rather implement that in a separate constraint class.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74973



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


[PATCH] D74463: [clang-tidy] Add new check avoid-adjacent-unrelated-parameters-of-the-same-type

2020-02-24 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal added a comment.

Discovered duplication: https://reviews.llvm.org/D69560


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74463



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


[PATCH] D75048: [ASTImporter] Improved import of AlignedAttr.

2020-02-24 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, martong, teemperor, gamesh411, 
Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

It is not enough to clone the attributes at import.
They can contain reference to objects that should be imported.
This work is done now for AlignedAttr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75048

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5887,6 +5887,39 @@
   EXPECT_FALSE(ToSM.isBeforeInTranslationUnit(Location2, Location1));
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportExprOfAlignmentAttr) {
+  // FIXME: These packed and aligned attributes could trigger an error situation
+  // where source location from 'From' context is referenced in 'To' context
+  // through evaluation of the alignof attribute.
+  // This happened if the 'alignof(A)' expression was not imported correctly.
+  Decl *FromTU = getTuDecl(
+  R"(
+  struct __attribute__((packed)) A { int __attribute__((aligned(8))) X; };
+  struct alignas(alignof(A)) S {};
+  )",
+  Lang_CXX11, "input.cc");
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, cxxRecordDecl(hasName("S"), unless(isImplicit(;
+  ASSERT_TRUE(FromD);
+
+  auto *ToD = Import(FromD, Lang_CXX11);
+  ASSERT_TRUE(ToD);
+
+  auto *FromAttr = FromD->getAttr();
+  auto *ToAttr = ToD->getAttr();
+  EXPECT_EQ(FromAttr->isInherited(), ToAttr->isInherited());
+  EXPECT_EQ(FromAttr->isPackExpansion(), ToAttr->isPackExpansion());
+  EXPECT_EQ(FromAttr->isImplicit(), ToAttr->isImplicit());
+  EXPECT_TRUE(ToAttr->getAlignmentExpr());
+
+  auto *ToA = FirstDeclMatcher().match(
+  ToD->getTranslationUnitDecl(),
+  cxxRecordDecl(hasName("A"), unless(isImplicit(;
+  // Ensure that 'struct A' was imported (through reference from attribute of
+  // 'S').
+  EXPECT_TRUE(ToA);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -7929,12 +7929,46 @@
 }
 
 Expected ASTImporter::Import(const Attr *FromAttr) {
-  Attr *ToAttr = FromAttr->clone(ToContext);
-  if (auto ToRangeOrErr = Import(FromAttr->getRange()))
-ToAttr->setRange(*ToRangeOrErr);
-  else
-return ToRangeOrErr.takeError();
-
+  Attr *ToAttr = nullptr;
+  SourceRange ToRange;
+  if (Error Err = importInto(ToRange, FromAttr->getRange()))
+return std::move(Err);
+
+  // FIXME: Is there some kind of AttrVisitor to use here?
+  switch (FromAttr->getKind()) {
+  case attr::Aligned: {
+auto *From = cast(FromAttr);
+AlignedAttr *To;
+if (From->isAlignmentExpr()) {
+  if (auto ToEOrErr = Import(From->getAlignmentExpr()))
+To = AlignedAttr::Create(ToContext, true, *ToEOrErr, ToRange,
+ FromAttr->getSyntax(),
+ From->getSemanticSpelling());
+  else
+return ToEOrErr.takeError();
+} else {
+  if (auto ToTOrErr = Import(From->getAlignmentType()))
+To = AlignedAttr::Create(ToContext, false, *ToTOrErr, ToRange,
+ FromAttr->getSyntax(),
+ From->getSemanticSpelling());
+  else
+return ToTOrErr.takeError();
+}
+To->setInherited(From->isInherited());
+To->setPackExpansion(From->isPackExpansion());
+To->setImplicit(From->isImplicit());
+ToAttr = To;
+break;
+  }
+  default:
+// FIXME: 'clone' copies every member but some of them should be imported.
+// Handle other Attrs that have parameters that should be imported.
+ToAttr = FromAttr->clone(ToContext);
+ToAttr->setRange(ToRange);
+break;
+  }
+  assert(ToAttr && "Attribute should be created.");
+  
   return ToAttr;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73967: Implement _ExtInt as an extended int type specifier.

2020-02-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 246198.
erichkeane added a subscriber: lattner.
erichkeane added a comment.

Update language extensions to document calling convention impact.

This patch should now be completely up to date based on the comments here and 
from cfe-dev, particularly those by @lattner


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

https://reviews.llvm.org/D73967

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenTBAA.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGen/ext-int-sanitizer.cpp
  clang/test/CodeGen/ext-int.cpp
  clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp
  clang/test/CodeGenOpenCL/ext-int-shift.cl
  clang/test/SemaCXX/ext-int.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1804,6 +1804,8 @@
 DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParm, Type)
 DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParmPack, Type)
 DEFAULT_TYPELOC_IMPL(Auto, Type)
+DEFAULT_TYPELOC_IMPL(ExtInt, Type)
+DEFAULT_TYPELOC_IMPL(DependentExtInt, Type)
 
 bool CursorVisitor::VisitCXXRecordDecl(CXXRecordDecl *D) {
   // Visit the nested-name-specifier, if present.
Index: clang/test/SemaCXX/ext-int.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ext-int.cpp
@@ -0,0 +1,266 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template
+struct HasExtInt {
+  _ExtInt(Bounds) b;
+  unsigned _ExtInt(Bounds) b2;
+};
+
+// Delcaring variables:
+_ExtInt(33) Declarations(_ExtInt(48) &Param) { // Useable in params and returns.
+  short _ExtInt(43) a; // expected-error {{'short _ExtInt' is invalid}}
+  _ExtInt(43) long b;  // expected-error {{'long _ExtInt' is invalid}}
+
+  // These should all be fine:
+  const _ExtInt(5) c = 3;
+  const unsigned _ExtInt(5) d; // expected-error {{default initialization of an object of const type 'const unsigned _ExtInt(5)'}}
+  unsigned _ExtInt(5) e = 5;
+  _ExtInt(5) unsigned f;
+
+  _ExtInt(-3) g; // expected-error{{signed _ExtInt must have a size of at least 2}}
+  _ExtInt(0) h; // expected-error{{signed _ExtInt must have a size of at least 2}}
+  _ExtInt(1) i; // expected-error{{signed _ExtInt must have a size of at least 2}}
+  _ExtInt(2) j;;
+  unsigned _ExtInt(0) k;// expected-error{{unsigned _ExtInt must have a size of at least 1}}
+  unsigned _ExtInt(1) l;
+  signed _ExtInt(1) m; // expected-error{{signed _ExtInt must have a size of at least 2}}
+
+  constexpr _ExtInt(6) n = 33; // expected-warning{{implicit conversion from 'int' to 'const _ExtInt(6)' changes value from 33 to -31}}
+  constexpr _ExtInt(7) o = 33;
+
+  // Check LLVM imposed max size.
+  _ExtInt(0xFF) p; // expected-error {{signed _ExtInt of sizes greater than 16777215 not supported}}
+  unsigned _ExtInt(0xFF) q; // expected-error {{unsigned _ExtInt of sizes greater than 16777215 not supported}}
+
+// Ensure template params are instantiated correctly.
+  // expected-error@5{{signed _ExtInt must have a size of at least 2}}
+  // expected-error@6{{unsigned _ExtInt must have a size of at least 1}}
+  // expected-note@+1{{in instantiation of template class }}
+  HasExtInt<-1> r;
+  // expected-error@5{{signed _ExtI

[PATCH] D74463: [clang-tidy] Add new check avoid-adjacent-unrelated-parameters-of-the-same-type

2020-02-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D74463#1889187 , @vingeldal wrote:

> In D74463#1889157 , @vingeldal wrote:
>
> > > - how do we either not warn on this by default or how does the user tell 
> > > us to not warn on it (without requiring them to jump through hoops like 
> > > changing the types of the arguments)?
> >
> > -I'v used comments in the source code to tell the tool to ignore cases that 
> > I'v identified as false positives. That has worked without any issues for 
> > me and I wouldn't say it's a hassle. Is that no longer supported in clang 
> > tidy or was I using another tool and just projected that memory on 
> > clang-tidy?
> >  I'm confident that clang-format atleast has a means of locally suppressing 
> > rules.
>
>
> Found what I was thinking of: "// 
> NOLINT(cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type)"
>  Do you think this is too much jumping through hoops or would that suffice as 
> a means to get rid of false positives?


We do support `NOLINT` comments in clang-tidy, but those tend to only be 
appropriate for code the user has control over and less appropriate for things 
the user often doesn't have control over. Given that this functionality is 
diagnosing function declarations, my concern is that a lot of the diagnostics 
will be in code the user cannot touch to add the markings (like system or 
third-party headers). Seeing how chatty the diagnostic is in practice will help 
determine what approach to take (maybe we need the ability to specify header 
files to disable the check for, maybe we need to ignore all system headers, 
etc).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74463



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


[clang] c8dadac - add release notes for ffp-model and ffp-exception-behavior

2020-02-24 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-02-24T06:42:05-08:00
New Revision: c8dadac228b7dd3a71d5fc25489d1b884a2b0f5e

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

LOG: add release notes for ffp-model and ffp-exception-behavior

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ba3937dd83ed..831ef32c6b8a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -66,6 +66,13 @@ New Compiler Flags
   attack for x86 architecture through automatic probing of each page of
   allocated stack.
 
+- -ffp-exception-behavior={ignore,maytrap,strict} allows the user to specify
+  the floating-point exception behavior.  The default setting is ``ignore``.
+
+- -ffp-model={precise,strict,fast} provides the user an umbrella option to
+  simplify access to the many single purpose floating point options. The 
default
+  setting is ``precise``.
+
 Deprecated Compiler Flags
 -
 



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


[PATCH] D74463: [clang-tidy] Add new check avoid-adjacent-unrelated-parameters-of-the-same-type

2020-02-24 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal abandoned this revision.
vingeldal added a comment.

Will proceed with instead contributing however I can to the more mature patch 
https://reviews.llvm.org/D69560


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74463



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


[PATCH] D75045: [analyzer] Improved check of `fgetc` in StreamChecker.

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:356
+State = State->set(
+StreamSym, StreamState{SS->K, false, SS->ShouldCallFerror});
+  }

Maybe adding a comment like `false /*Feof*/` could make this more readable. 
Even better, using two different strong types instead of the bool args could 
make it even more safe, but if that's too much hassle then it is may be not 
worth (I don't know if LLVM has a proper infrastructure for strong types).



Comment at: clang/test/Analysis/stream.c:182
+
+void check_fgetc_error() {
+  FILE *fp = fopen("foo.c", "r");

Do you have tests for `getc` as well? Maybe we could have at least one for getc 
too.



Comment at: clang/test/Analysis/stream.c:218
+feof(fp);
+fclose(fp); // expected-warning {{Should call}}
+  }

Perhaps `Should call ferror` is more informative for the readers of the tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75045



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


[PATCH] D69560: [clang-tidy] Add 'cppcoreguidelines-avoid-adjacent-arguments-of-same-type' check

2020-02-24 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal added a comment.

Nice! Do you have any numbers on the amount of false positives this check 
produces, or the ratio of false and true positives?
I recently started work on this check myself but didn't get very far before I 
discovered this patch and abandoned mine.
Before abandoning I got some feedback though; there were concerns that there 
would be way to many false positives.

There were requests both to add heuristics to minimize false positives, as I 
see you have done nicely,
and to provide some data as to how the check performs with regard to false 
positives.




Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AdjacentArgumentsOfSameTypeCheck.cpp:474
+// Default to 3 so the users don't get a warning for every possible thing.
+static const unsigned DefaultMinLength = 3;
+

Am I getting this right, is this the number of consecutive arguments of the 
same type which is required for this check to print a diagnostic? If so: why 
not set the default value to 2? -I think that's what a user who just read the 
C++ Core Guidelines would expect.


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

https://reviews.llvm.org/D69560



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


[PATCH] D75045: [analyzer] Improved check of `fgetc` in StreamChecker.

2020-02-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a comment.
This revision now requires changes to proceed.

I'm a bit confused as to what this patch aims to do. Once again, I'd kindly ask 
you to discuss for a bit before updating this patch.

---

The rule states that after reaching `EOF` **both** `ferror` and `feof` should 
be called. I'm a bit confused here -- isn't this problem a property of `EOF` 
rather then `getc()` specifically? Also, expecting each maintainer of this code 
to call `checkErrorState` whenever a new stream function is implemented //as 
well as// keeping in mind that state transitions should be made against a new 
`ExplodedNode` makes me think that we could do better.

I think we should do some ground work before progressing further. The checker 
currently doesn't implement the state where we know that the stream is an error 
state (we got `EOF` from it). Shouldn't we do that first? After that, the rule 
you want to enforce may be more appropriate to originate from 
`checkDeadSymbols` when a stream in said state isn't checked properly, which 
seems to be a lot more in line with the rule.

---

The test file contains tests where `EOF` isn't encountered once but we're 
emitting a warning that `ferror` and `feof` should've been called, yet the rule 
states that

> Calling both functions on each iteration of a loop adds significant overhead, 
> so a good strategy is to temporarily trust EOF and WEOF within the loop but 
> verify them with feof() and ferror() following the loop.

Could we have the test cases from the CERT site, or something similar with a 
loop?

---

One thing that worries me is compliant non-portable solution:

  #include 
  #include 
  #include 
   
  void func(void) {
int c;
static_assert(UCHAR_MAX < UINT_MAX, "FIO34-C violation");
   
do {
  c = getchar();
} while (c != EOF);
  }

We would totally emit errors for this. There are some solutions to this:

- Assume that the user will turn off this checker in this case.
- Check the `TranslationUnitDecl` for static asserts. If not present, suggest 
to put it in. This would make this warning more appropriate to come from the 
`portability` package.




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:255-261
+  if (EOFv == 0) {
+if (const llvm::Optional OptInt =
+tryExpandAsInteger("EOF", C.getPreprocessor()))
+  EOFv = *OptInt;
+else
+  EOFv = -1;
+  }

I'm 99% sure that the `Preprocessor` is retrievable in the checker registry 
function (`register*Checker`), and this code should be moved there, and `EOFv ` 
be made non-mutable. 



Comment at: clang/test/Analysis/stream.c:188
+C = fgetc(fp);
+fread(0, 0, 0, fp); // expected-warning {{Should call}}
+fread(0, 0, 0, fp);

Are we sure that this is the error message we want to emit here? Sure, not 
checking whether the stream is in an error state is a recipe for disaster, but 
this seems to clash with
> Should call 'feof' and 'ferror' after failed character read.
as error here is not even checking the return value. Shouldn't we say
> Should check the return value of `fgetc` before ...
instead?



Comment at: clang/test/Analysis/stream.c:246-247
+if (C == EOF) {
+  feof(fp);
+  ferror(fp);
+}

I bet this isn't how we envision how these function to be used. Maybe 
`ReturnValueChecker` could be deployed here? In any case, that would be a topic 
of a different revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75045



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


[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-02-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

FYI I've been seeing your patches to this checker and I will respond to them, 
but I need to do some learning on my own before having the confidence to accept 
or request changes. Working on it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74973



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


[PATCH] D75040: [ASTMatchers] Adds a matcher called `hasAnyOperatorName`

2020-02-24 Thread Nathan James via Phabricator via cfe-commits
njames93 requested review of this revision.
njames93 marked 3 inline comments as done.
njames93 added a comment.

I have fixed up the docs to be more in line with other matchers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75040



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


[PATCH] D75040: [ASTMatchers] Adds a matcher called `hasAnyOperatorName`

2020-02-24 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 246203.
njames93 added a comment.

- Improved docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75040

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/tools/dump_ast_matchers.py
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1123,6 +1123,19 @@
   EXPECT_TRUE(notMatches("void x() { true && false; }", OperatorOr));
 }
 
+TEST(MatchBinaryOperator, HasAnyOperatorName) {
+  StatementMatcher Matcher =
+  binaryOperator(hasAnyOperatorName("+", "-", "*", "/"));
+
+  EXPECT_TRUE(matches("int x(int I) { return I + 2; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return I - 2; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return I * 2; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return I / 2; }", Matcher));
+  EXPECT_TRUE(notMatches("int x(int I) { return I % 2; }", Matcher));
+  // Ensure '+= isn't mistaken.
+  EXPECT_TRUE(notMatches("void x(int &I) { I += 1; }", Matcher));
+}
+
 TEST(MatchBinaryOperator, HasLHSAndHasRHS) {
   StatementMatcher OperatorTrueFalse =
 binaryOperator(hasLHS(cxxBoolLiteral(equals(true))),
@@ -1255,6 +1268,18 @@
   EXPECT_TRUE(notMatches("void x() { true; } ", OperatorNot));
 }
 
+TEST(MatchUnaryOperator, HasAnyOperatorName) {
+  StatementMatcher Matcher = unaryOperator(hasAnyOperatorName("-", "*", "++"));
+
+  EXPECT_TRUE(matches("int x(int *I) { return *I; }", Matcher));
+  EXPECT_TRUE(matches("int x(int I) { return -I; }", Matcher));
+  EXPECT_TRUE(matches("void x(int &I) { I++; }", Matcher));
+  EXPECT_TRUE(matches("void x(int &I) { ++I; }", Matcher));
+  EXPECT_TRUE(notMatches("void x(int &I) { I--; }", Matcher));
+  EXPECT_TRUE(notMatches("void x(int &I) { --I; }", Matcher));
+  EXPECT_TRUE(notMatches("int *x(int &I) { return &I; }", Matcher));
+}
+
 TEST(MatchUnaryOperator, HasUnaryOperand) {
   StatementMatcher OperatorOnFalse =
 unaryOperator(hasUnaryOperand(cxxBoolLiteral(equals(false;
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -243,6 +243,7 @@
   REGISTER_MATCHER(hasAnyConstructorInitializer);
   REGISTER_MATCHER(hasAnyDeclaration);
   REGISTER_MATCHER(hasAnyName);
+  REGISTER_MATCHER(hasAnyOperatorName);
   REGISTER_MATCHER(hasAnyParameter);
   REGISTER_MATCHER(hasAnyPlacementArg);
   REGISTER_MATCHER(hasAnySelector);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -380,6 +380,10 @@
   return hasAnySelectorMatcher(vectorFromRefs(NameRefs));
 }
 
+HasOpNameMatcher hasAnyOperatorNameFunc(ArrayRef NameRefs) {
+  return HasOpNameMatcher(vectorFromRefs(NameRefs));
+}
+
 HasNameMatcher::HasNameMatcher(std::vector N)
 : UseUnqualifiedMatch(std::all_of(
   N.begin(), N.end(),
@@ -854,6 +858,10 @@
 const internal::VariadicFunction, StringRef,
  internal::hasAnyNameFunc>
 hasAnyName = {};
+
+const internal::VariadicFunction
+hasAnyOperatorName = {};
 const internal::VariadicFunction, StringRef,
  internal::hasAnySelectorFunc>
 hasAnySelector = {};
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1858,6 +1858,47 @@
 llvm::Optional
 getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc,
const ASTContext &Context);
+
+/// Matches overloaded operators with a specific name.
+///
+/// The type argument ArgT is not used by this matcher but is used by
+/// PolymorphicMatcherWithParam1 and should be std::vector>.
+template >
+class HasAnyOperatorNameMatcher : public SingleNodeMatcherInterface {
+  static_assert(std::is_same::value ||
+std::is_same::value,
+"Matcher only supports `BinaryOperator` and `UnaryOperator`");
+  static_assert(std::is_same>::value,
+"Matcher ArgT must be std::vector");
+
+public:
+  explicit HasAnyOperatorNameMatcher(std::vector Names)
+  : SingleNodeMatcherInterface(), Names(std::move(Names)) {}
+
+  bool matchesNode(cons

[clang] 8bee52b - [AIX][Frontend] C++ ABI customizations for AIX boilerplate

2020-02-24 Thread Xiangling Liao via cfe-commits

Author: Xiangling Liao
Date: 2020-02-24T10:26:51-05:00
New Revision: 8bee52bdb54a51ccfe1eb6c6ed5077132c2950a1

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

LOG: [AIX][Frontend] C++ ABI customizations for AIX boilerplate

This PR enables "XL" C++ ABI in frontend AST to IR codegen. And it is driven by
static init work. The current kind in Clang by default is Generic Itanium, which
has different behavior on static init with IBM xlclang compiler on AIX.

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

Added: 
clang/test/CodeGen/static-init.cpp

Modified: 
clang/include/clang/Basic/TargetCXXABI.h
clang/lib/AST/ASTContext.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetCXXABI.h 
b/clang/include/clang/Basic/TargetCXXABI.h
index 1ab45d2ce9a1..93f70fc70dd8 100644
--- a/clang/include/clang/Basic/TargetCXXABI.h
+++ b/clang/include/clang/Basic/TargetCXXABI.h
@@ -109,6 +109,13 @@ class TargetCXXABI {
 ///   - constructors and destructors return 'this', as in ARM.
 Fuchsia,
 
+/// The XL ABI is the ABI used by IBM xlclang compiler and is a modified
+/// version of the Itanium ABI.
+///
+/// The relevant changes from the Itanium ABI are:
+///   - static initialization is adjusted to use sinit and sterm functions;
+XL,
+
 /// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and
 /// compatible compilers).
 ///
@@ -148,6 +155,7 @@ class TargetCXXABI {
 case WatchOS:
 case GenericMIPS:
 case WebAssembly:
+case XL:
   return true;
 
 case Microsoft:
@@ -168,6 +176,7 @@ class TargetCXXABI {
 case WatchOS:
 case GenericMIPS:
 case WebAssembly:
+case XL:
   return false;
 
 case Microsoft:
@@ -202,6 +211,7 @@ class TargetCXXABI {
 case iOS64:
 case WatchOS:
 case Microsoft:
+case XL:
   return true;
 }
 llvm_unreachable("bad ABI kind");
@@ -278,6 +288,7 @@ class TargetCXXABI {
 case iOS:   // old iOS compilers did not follow this rule
 case Microsoft:
 case GenericMIPS:
+case XL:
   return true;
 }
 llvm_unreachable("bad ABI kind");
@@ -315,6 +326,7 @@ class TargetCXXABI {
 case GenericARM:
 case iOS:
 case GenericMIPS:
+case XL:
   return UseTailPaddingUnlessPOD03;
 
 // iOS on ARM64 and WebAssembly use the C++11 POD rules.  They do not honor

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 50a0c3d76da2..b4527dc4b52a 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -874,6 +874,7 @@ CXXABI *ASTContext::createCXXABI(const TargetInfo &T) {
   case TargetCXXABI::GenericMIPS:
   case TargetCXXABI::GenericItanium:
   case TargetCXXABI::WebAssembly:
+  case TargetCXXABI::XL:
 return CreateItaniumCXXABI(*this);
   case TargetCXXABI::Microsoft:
 return CreateMicrosoftCXXABI(*this);
@@ -10253,6 +10254,7 @@ MangleContext *ASTContext::createMangleContext(const 
TargetInfo *T) {
   case TargetCXXABI::iOS64:
   case TargetCXXABI::WebAssembly:
   case TargetCXXABI::WatchOS:
+  case TargetCXXABI::XL:
 return ItaniumMangleContext::create(*this, getDiagnostics());
   case TargetCXXABI::Microsoft:
 return MicrosoftMangleContext::create(*this, getDiagnostics());

diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 70fac030bc5d..e57ad7b9eeaf 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -706,6 +706,8 @@ class AIXTargetInfo : public OSTargetInfo {
 public:
   AIXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
+this->TheCXXABI.set(TargetCXXABI::XL);
+
 if (this->PointerWidth == 64) {
   this->WCharType = this->UnsignedInt;
 } else {

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 235a40501afc..d4ed486b4079 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -83,6 +83,7 @@ static CGCXXABI *createCXXABI(CodeGenModule &CGM) {
   case TargetCXXABI::GenericMIPS:
   case TargetCXXABI::GenericItanium:
   case TargetCXXABI::WebAssembly:
+  case TargetCXXABI::XL:
 return CreateItaniumCXXABI(CGM);
   case TargetCXXABI::Microsoft:
 return CreateMicrosoftCXXABI(CGM);

diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 057c726e355e..c8a73c2757ab 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -516,6 +516,16 @@ class WebAssemblyCXXABI final : public ItaniumCXXABI {
   }
   bool can

[PATCH] D73285: [OpenMP][OMPIRBuilder][BugFix] Handle Unreachable Finalization blocks in `parallel` generation

2020-02-24 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim abandoned this revision.
fghanim added a comment.

The bug this revision attempted to fix has been resolved as part of patch 
D74562 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73285



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


[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-02-24 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 246204.
hliao added a comment.

Rebase to the trunk.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/global-initializers-host.cu
  clang/test/SemaCUDA/hip-pinned-shadow.cu

Index: clang/test/SemaCUDA/hip-pinned-shadow.cu
===
--- clang/test/SemaCUDA/hip-pinned-shadow.cu
+++ clang/test/SemaCUDA/hip-pinned-shadow.cu
@@ -13,13 +13,19 @@
 
 template 
 struct texture : public textureReference {
+// expected-note@-1{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-2{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-3{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-4{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
 texture() { a = 1; }
+// expected-note@-1{{candidate constructor not viable: call to __host__ function from __device__ function}}
+// expected-note@-2{{candidate constructor not viable: call to __host__ function from __device__ function}}
 };
 
 __hip_pinned_shadow__ texture tex;
 __device__ __hip_pinned_shadow__ texture tex2; // expected-error{{'hip_pinned_shadow' and 'device' attributes are not compatible}}
-// expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-// expected-note@-2{{conflicting attribute is here}}
+// expected-note@-1{{conflicting attribute is here}}
+// expected-error@-2{{no matching constructor for initialization of 'texture'}}
 __constant__ __hip_pinned_shadow__ texture tex3; // expected-error{{'hip_pinned_shadow' and 'constant' attributes are not compatible}}
-  // expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-  // expected-note@-2{{conflicting attribute is here}}
+  // expected-note@-1{{conflicting attribute is here}}
+  // expected-error@-2{{no matching constructor for initialization of 'texture'}}
Index: clang/test/SemaCUDA/global-initializers-host.cu
===
--- clang/test/SemaCUDA/global-initializers-host.cu
+++ clang/test/SemaCUDA/global-initializers-host.cu
@@ -6,12 +6,14 @@
 // module initializer.
 
 struct S {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
   __device__ S() {}
-  // expected-note@-1 {{'S' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 
 S s;
-// expected-error@-1 {{reference to __device__ function 'S' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'S'}}
 
 struct T {
   __host__ __device__ T() {}
@@ -19,14 +21,17 @@
 T t;  // No error, this is OK.
 
 struct U {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const U' for 1st argument}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'U' for 1st argument}}
   __host__ U() {}
+  // expected-note@-1 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
   __device__ U(int) {}
-  // expected-note@-1 {{'U' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 U u(42);
-// expected-error@-1 {{reference to __device__ function 'U' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'U'}}
 
 __device__ int device_fn() { return 42; }
-// expected-note@-1 {{'device_fn' declared here}}
+// expected-note@-1 {{candidate function not viable: call to __device__ functio

[PATCH] D74015: [AIX][Frontend] C++ ABI customizations for AIX boilerplate

2020-02-24 Thread Xiangling Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bee52bdb54a: [AIX][Frontend] C++ ABI customizations for AIX 
boilerplate (authored by Xiangling_L).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74015

Files:
  clang/include/clang/Basic/TargetCXXABI.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- /dev/null
+++ clang/test/CodeGen/static-init.cpp
@@ -0,0 +1,12 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
+// RUN: 2>&1 | FileCheck %s
+
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
+// RUN: 2>&1 | FileCheck %s
+
+struct test {
+  test();
+  ~test();
+} t;
+
+// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -516,6 +516,16 @@
   }
   bool canCallMismatchedFunctionType() const override { return false; }
 };
+
+class XLCXXABI final : public ItaniumCXXABI {
+public:
+  explicit XLCXXABI(CodeGen::CodeGenModule &CGM)
+  : ItaniumCXXABI(CGM) {}
+
+  void registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,
+  llvm::FunctionCallee dtor,
+  llvm::Constant *addr) override;
+};
 }
 
 CodeGen::CGCXXABI *CodeGen::CreateItaniumCXXABI(CodeGenModule &CGM) {
@@ -546,6 +556,9 @@
   case TargetCXXABI::WebAssembly:
 return new WebAssemblyCXXABI(CGM);
 
+  case TargetCXXABI::XL:
+return new XLCXXABI(CGM);
+
   case TargetCXXABI::GenericItanium:
 if (CGM.getContext().getTargetInfo().getTriple().getArch()
 == llvm::Triple::le32) {
@@ -4407,3 +4420,11 @@
 NormalCleanup, cast(CGF.CurrentFuncletPad));
   ItaniumCXXABI::emitBeginCatch(CGF, C);
 }
+
+/// Register a global destructor as best as we know how.
+void XLCXXABI::registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,
+  llvm::FunctionCallee dtor,
+  llvm::Constant *addr) {
+  llvm::report_fatal_error("Static initialization has not been implemented on"
+   " XL ABI yet.");
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -83,6 +83,7 @@
   case TargetCXXABI::GenericMIPS:
   case TargetCXXABI::GenericItanium:
   case TargetCXXABI::WebAssembly:
+  case TargetCXXABI::XL:
 return CreateItaniumCXXABI(CGM);
   case TargetCXXABI::Microsoft:
 return CreateMicrosoftCXXABI(CGM);
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -706,6 +706,8 @@
 public:
   AIXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
+this->TheCXXABI.set(TargetCXXABI::XL);
+
 if (this->PointerWidth == 64) {
   this->WCharType = this->UnsignedInt;
 } else {
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -874,6 +874,7 @@
   case TargetCXXABI::GenericMIPS:
   case TargetCXXABI::GenericItanium:
   case TargetCXXABI::WebAssembly:
+  case TargetCXXABI::XL:
 return CreateItaniumCXXABI(*this);
   case TargetCXXABI::Microsoft:
 return CreateMicrosoftCXXABI(*this);
@@ -10253,6 +10254,7 @@
   case TargetCXXABI::iOS64:
   case TargetCXXABI::WebAssembly:
   case TargetCXXABI::WatchOS:
+  case TargetCXXABI::XL:
 return ItaniumMangleContext::create(*this, getDiagnostics());
   case TargetCXXABI::Microsoft:
 return MicrosoftMangleContext::create(*this, getDiagnostics());
Index: clang/include/clang/Basic/TargetCXXABI.h
===
--- clang/include/clang/Basic/TargetCXXABI.h
+++ clang/include/clang/Basic/TargetCXXABI.h
@@ -109,6 +109,13 @@
 ///   - constructors and destructors return 'this', as in ARM.
 Fuchsia,
 
+/// The XL ABI is the ABI used by IBM xlclang compiler and is a modified
+/// version of the Itanium ABI.
+///
+/// The relevant changes from the Itanium ABI are:
+///   - static initialization is adjusted to use sinit and sterm functions;
+XL,
+
 /// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and
 /// compatible compilers).
 ///
@@ -148,6 +155,7 @@
  

[PATCH] D72035: [analyzer][NFC] Use CallEvent checker callback in GenericTaintChecker

2020-02-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: martong.

Wow. Its a joy to see you do C++. LGTM. Are you planning to introduce 
`CallDescriptionMap` at one point? :)




Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:492-509
+const auto OneOf = [FDecl](const auto &... Name) {
+  // FIXME: use fold expression in C++17
+  using unused = int[];
+  bool ret = false;
+  static_cast(unused{
+  0, (ret |= CheckerContext::isCLibraryFunction(FDecl, Name), 0)...});
+  return ret;

Whoa, this is amazing, but looks like a google interview question or something 
-- is this a technique I should know about it? I feel like we kinda sacrificed 
readability for coolness.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72035



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


[clang] d66d25f - [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor class.

2020-02-24 Thread Alexey Bataev via cfe-commits

Author: cchen
Date: 2020-02-24T10:30:41-05:00
New Revision: d66d25f83824e2d72e06bf0813cc9e9e564dd74c

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

LOG: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using 
StmtVisitor class.

Summary: This step is the preparation of allowing lvalue in map/motion clause.

Reviewers: ABataev, jdoerfert

Reviewed By: ABataev

Subscribers: guansong, cfe-commits

Tags: #clang, #openmp

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_messages.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index ea1011067130..e12bae2fd464 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15431,256 +15431,282 @@ static bool 
checkArrayExpressionDoesNotReferToUnitySize(Sema &SemaRef,
   return ConstLength.getSExtValue() != 1;
 }
 
-// Return the expression of the base of the mappable expression or null if it
-// cannot be determined and do all the necessary checks to see if the 
expression
-// is valid as a standalone mappable expression. In the process, record all the
-// components of the expression.
-static const Expr *checkMapClauseExpressionBase(
-Sema &SemaRef, Expr *E,
-OMPClauseMappableExprCommon::MappableExprComponentList &CurComponents,
-OpenMPClauseKind CKind, bool NoDiagnose) {
-  SourceLocation ELoc = E->getExprLoc();
-  SourceRange ERange = E->getSourceRange();
-
-  // The base of elements of list in a map clause have to be either:
-  //  - a reference to variable or field.
-  //  - a member expression.
-  //  - an array expression.
-  //
-  // E.g. if we have the expression 'r.S.Arr[:12]', we want to retrieve the
-  // reference to 'r'.
-  //
-  // If we have:
-  //
-  // struct SS {
-  //   Bla S;
-  //   foo() {
-  // #pragma omp target map (S.Arr[:12]);
-  //   }
-  // }
-  //
-  // We want to retrieve the member expression 'this->S';
+// The base of elements of list in a map clause have to be either:
+//  - a reference to variable or field.
+//  - a member expression.
+//  - an array expression.
+//
+// E.g. if we have the expression 'r.S.Arr[:12]', we want to retrieve the
+// reference to 'r'.
+//
+// If we have:
+//
+// struct SS {
+//   Bla S;
+//   foo() {
+// #pragma omp target map (S.Arr[:12]);
+//   }
+// }
+//
+// We want to retrieve the member expression 'this->S';
 
+// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2]
+//  If a list item is an array section, it must specify contiguous storage.
+//
+// For this restriction it is sufficient that we make sure only references
+// to variables or fields and array expressions, and that no array sections
+// exist except in the rightmost expression (unless they cover the whole
+// dimension of the array). E.g. these would be invalid:
+//
+//   r.ArrS[3:5].Arr[6:7]
+//
+//   r.ArrS[3:5].x
+//
+// but these would be valid:
+//   r.ArrS[3].Arr[6:7]
+//
+//   r.ArrS[3].x
+namespace {
+class MapBaseChecker final : public StmtVisitor {
+  Sema &SemaRef;
+  OpenMPClauseKind CKind = OMPC_unknown;
+  OMPClauseMappableExprCommon::MappableExprComponentList &Components;
+  bool NoDiagnose = false;
   const Expr *RelevantExpr = nullptr;
-
-  // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2]
-  //  If a list item is an array section, it must specify contiguous storage.
-  //
-  // For this restriction it is sufficient that we make sure only references
-  // to variables or fields and array expressions, and that no array sections
-  // exist except in the rightmost expression (unless they cover the whole
-  // dimension of the array). E.g. these would be invalid:
-  //
-  //   r.ArrS[3:5].Arr[6:7]
-  //
-  //   r.ArrS[3:5].x
-  //
-  // but these would be valid:
-  //   r.ArrS[3].Arr[6:7]
-  //
-  //   r.ArrS[3].x
-
   bool AllowUnitySizeArraySection = true;
   bool AllowWholeSizeArraySection = true;
+  SourceLocation ELoc;
+  SourceRange ERange;
 
-  while (!RelevantExpr) {
-E = E->IgnoreParenImpCasts();
-
-if (auto *CurE = dyn_cast(E)) {
-  if (!isa(CurE->getDecl()))
-return nullptr;
-
-  RelevantExpr = CurE;
+  void emitErrorMsg() {
+if (!NoDiagnose) {
+  // If nothing else worked, this is not a valid map clause expression.
+  SemaRef.Diag(ELoc, 
diag::err_omp_expected_named_var_member_or_array_expression)
+<< ERange;
+}
+  }
 
-  // If we got a reference to a declaration, we should not expect any array
-  // section before that.
-  AllowUnitySizeArraySection = false;
-  AllowWholeSizeArraySection = false;
+public:
+  bool VisitDeclRefExpr(DeclRefExpr *DRE) {
+if (!isa(DRE->getDecl())) {
+  emitErrorMsg();
+  return fals

[PATCH] D75053: [clangd] Disable ExtractVariable for C

2020-02-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: usaxena95.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Currently extract variable doesn't spell the type explicitly and just
uses an `auto` instead, which is not available in C.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75053

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -230,6 +230,14 @@
   )cpp";
   EXPECT_AVAILABLE(AvailableCases);
 
+  ExtraArgs = {"-xc"};
+  const char *AvailableButC = R"cpp(
+void foo() {
+  int x = [[1]];
+})cpp";
+  EXPECT_UNAVAILABLE(AvailableButC);
+  ExtraArgs = {};
+
   const char *NoCrashCases = R"cpp(
 // error-ok: broken code, but shouldn't crash
 template
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -450,6 +450,10 @@
   if (Inputs.SelectionBegin == Inputs.SelectionEnd)
 return false;
   const ASTContext &Ctx = Inputs.AST->getASTContext();
+  // FIXME: Enable C (and maybe objective-c) once we start spelling types
+  // explicitly instead of making use of auto.
+  if (!Ctx.getLangOpts().CPlusPlus)
+return false;
   const SourceManager &SM = Inputs.AST->getSourceManager();
   if (const SelectionTree::Node *N =
   computeExtractedExpr(Inputs.ASTSelection.commonAncestor()))


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -230,6 +230,14 @@
   )cpp";
   EXPECT_AVAILABLE(AvailableCases);
 
+  ExtraArgs = {"-xc"};
+  const char *AvailableButC = R"cpp(
+void foo() {
+  int x = [[1]];
+})cpp";
+  EXPECT_UNAVAILABLE(AvailableButC);
+  ExtraArgs = {};
+
   const char *NoCrashCases = R"cpp(
 // error-ok: broken code, but shouldn't crash
 template
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -450,6 +450,10 @@
   if (Inputs.SelectionBegin == Inputs.SelectionEnd)
 return false;
   const ASTContext &Ctx = Inputs.AST->getASTContext();
+  // FIXME: Enable C (and maybe objective-c) once we start spelling types
+  // explicitly instead of making use of auto.
+  if (!Ctx.getLangOpts().CPlusPlus)
+return false;
   const SourceManager &SM = Inputs.AST->getSourceManager();
   if (const SelectionTree::Node *N =
   computeExtractedExpr(Inputs.ASTSelection.commonAncestor()))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69746: [analyzer] FixItHint: Apply and test hints with the Clang-Tidy's script

2020-02-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Thanks for the reviews! Are we good to go?




Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:112
   void enableFixitsAsRemarks() { FixitsAsRemarks = true; }
+  void enableFixItApplication() { ApplyFixIts = true; }
 

alexfh wrote:
> nit: I'd suggest naming the method closer to the name of the corresponding 
> field, e.g. `enableApplyFixIts`. Why isn't this `setApplyFixIts(bool)` btw?
We do not support the disable way of options, so let us make it 
`enableApplyFixIts()`.


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

https://reviews.llvm.org/D69746



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


[PATCH] D69746: [analyzer] FixItHint: Apply and test hints with the Clang-Tidy's script

2020-02-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 246209.
Charusso marked 4 inline comments as done.
Charusso retitled this revision from "[analyzer] FixItHint: Apply and test 
hints with the Clang Tidy's script" to "[analyzer] FixItHint: Apply and test 
hints with the Clang-Tidy's script".
Charusso added a comment.

- Fix.


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

https://reviews.llvm.org/D69746

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/check-analyzer-fixit.py
  clang/test/Analysis/virtualcall-fixit.cpp
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -77,6 +77,11 @@
 if config.clang_staticanalyzer_z3 == '1':
 config.available_features.add('z3')
 
+check_analyzer_fixit_path = os.path.join(
+config.test_source_root, "Analysis", "check-analyzer-fixit.py")
+config.substitutions.append(
+('%check_analyzer_fixit',
+ '%s %s' % (config.python_executable, check_analyzer_fixit_path)))
 
 llvm_config.add_tool_substitutions(tools, tool_dirs)
 
Index: clang/test/Analysis/virtualcall-fixit.cpp
===
--- /dev/null
+++ clang/test/Analysis/virtualcall-fixit.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_analyzer_fixit %s %t \
+// RUN:   -analyzer-checker=core,optin.cplusplus.VirtualCall \
+// RUN:   -analyzer-config optin.cplusplus.VirtualCall:ShowFixIts=true
+
+struct S {
+  virtual void foo();
+  S() {
+foo();
+// expected-warning@-1 {{Call to virtual method 'S::foo' during construction bypasses virtual dispatch}}
+// CHECK-FIXES: S::foo();
+  }
+  ~S();
+};
Index: clang/test/Analysis/check-analyzer-fixit.py
===
--- /dev/null
+++ clang/test/Analysis/check-analyzer-fixit.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+#
+#===- check-analyzer-fixit.py - Static Analyzer test helper ---*- python -*-===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#======#
+#
+# This file copy-pasted mostly from the Clang-Tidy's 'check_clang_tidy.py'.
+#
+#======#
+
+r"""
+Clang Static Analyzer test helper
+=
+
+This script runs the Analyzer in fix-it mode and verify fixes, warnings, notes.
+
+Usage:
+  check-analyzer-fixit.py   [analyzer arguments]
+
+Example:
+  // RUN: %check-analyzer-fixit %s %t -analyzer-checker=core
+"""
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+
+
+def write_file(file_name, text):
+with open(file_name, 'w') as f:
+f.write(text)
+
+
+def run_test_once(args, extra_args):
+input_file_name = args.input_file_name
+temp_file_name = args.temp_file_name
+clang_analyzer_extra_args = extra_args
+
+file_name_with_extension = input_file_name
+_, extension = os.path.splitext(file_name_with_extension)
+if extension not in ['.c', '.hpp', '.m', '.mm']:
+extension = '.cpp'
+temp_file_name = temp_file_name + extension
+
+with open(input_file_name, 'r') as input_file:
+input_text = input_file.read()
+
+# Remove the contents of the CHECK lines to avoid CHECKs matching on
+# themselves.  We need to keep the comments to preserve line numbers while
+# avoiding empty lines which could potentially trigger formatting-related
+# checks.
+cleaned_test = re.sub('// *CHECK-[A-Z0-9\-]*:[^\r\n]*', '//', input_text)
+write_file(temp_file_name, cleaned_test)
+
+original_file_name = temp_file_name + ".orig"
+write_file(original_file_name, cleaned_test)
+
+try:
+builtin_include_dir = subprocess.check_output(
+['clang', '-print-file-name=include'], stderr=subprocess.STDOUT)
+except subprocess.CalledProcessError as e:
+print('Cannot print Clang include directory: ' + e.output.decode())
+
+builtin_include_dir = os.path.normpath(builtin_include_dir)
+
+args = (['clang', '-cc1', '-internal-isystem', builtin_include_dir,
+ '-nostdsysteminc', '-analyze', '-analyzer-constraints=range',
+ '-analyzer-config', 'apply-fixits=true']
++ clang_analyzer_extra_args + ['-verify', temp_file_name])
+
+print('Running ' + str(args) + '...')
+
+try:
+clang_analyzer_output = \
+subprocess.check_output(args, stderr=subprocess.STDOUT).decode()
+except subprocess.CalledProcessError as e:
+print('Clang Stati

[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor class.

2020-02-24 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd66d25f83824: [OpenMP] Refactor the analysis in 
checkMapClauseBaseExpression using… (authored by cchen, committed by ABataev).

Changed prior to commit:
  https://reviews.llvm.org/D74970?vs=245995&id=246214#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74970

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_messages.cpp

Index: clang/test/OpenMP/target_messages.cpp
===
--- clang/test/OpenMP/target_messages.cpp
+++ clang/test/OpenMP/target_messages.cpp
@@ -50,6 +50,12 @@
   int b;
 #pragma omp target map(this[1]) // expected-note {{expected 'this' subscript expression on map clause to be 'this[0]'}} // expected-error {{invalid 'this' expression on 'map' clause}}
   int c;
+#pragma omp target map(foo) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
+  int d;
+#pragma omp target map(zee) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
+  int e;
+#pragma omp target map(this->zee) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
+  int f;
   }
 };
 
@@ -110,6 +116,14 @@
   #pragma omp target
   for (int n = 0; n < 100; ++n) {}
 
+  #pragma omp target map(foo) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
+  {}
+
+  S s;
+
+  #pragma omp target map(s.zee) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
+  {}
+
   return 0;
 }
 
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15431,256 +15431,282 @@
   return ConstLength.getSExtValue() != 1;
 }
 
-// Return the expression of the base of the mappable expression or null if it
-// cannot be determined and do all the necessary checks to see if the expression
-// is valid as a standalone mappable expression. In the process, record all the
-// components of the expression.
-static const Expr *checkMapClauseExpressionBase(
-Sema &SemaRef, Expr *E,
-OMPClauseMappableExprCommon::MappableExprComponentList &CurComponents,
-OpenMPClauseKind CKind, bool NoDiagnose) {
-  SourceLocation ELoc = E->getExprLoc();
-  SourceRange ERange = E->getSourceRange();
-
-  // The base of elements of list in a map clause have to be either:
-  //  - a reference to variable or field.
-  //  - a member expression.
-  //  - an array expression.
-  //
-  // E.g. if we have the expression 'r.S.Arr[:12]', we want to retrieve the
-  // reference to 'r'.
-  //
-  // If we have:
-  //
-  // struct SS {
-  //   Bla S;
-  //   foo() {
-  // #pragma omp target map (S.Arr[:12]);
-  //   }
-  // }
-  //
-  // We want to retrieve the member expression 'this->S';
+// The base of elements of list in a map clause have to be either:
+//  - a reference to variable or field.
+//  - a member expression.
+//  - an array expression.
+//
+// E.g. if we have the expression 'r.S.Arr[:12]', we want to retrieve the
+// reference to 'r'.
+//
+// If we have:
+//
+// struct SS {
+//   Bla S;
+//   foo() {
+// #pragma omp target map (S.Arr[:12]);
+//   }
+// }
+//
+// We want to retrieve the member expression 'this->S';
 
+// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2]
+//  If a list item is an array section, it must specify contiguous storage.
+//
+// For this restriction it is sufficient that we make sure only references
+// to variables or fields and array expressions, and that no array sections
+// exist except in the rightmost expression (unless they cover the whole
+// dimension of the array). E.g. these would be invalid:
+//
+//   r.ArrS[3:5].Arr[6:7]
+//
+//   r.ArrS[3:5].x
+//
+// but these would be valid:
+//   r.ArrS[3].Arr[6:7]
+//
+//   r.ArrS[3].x
+namespace {
+class MapBaseChecker final : public StmtVisitor {
+  Sema &SemaRef;
+  OpenMPClauseKind CKind = OMPC_unknown;
+  OMPClauseMappableExprCommon::MappableExprComponentList &Components;
+  bool NoDiagnose = false;
   const Expr *RelevantExpr = nullptr;
-
-  // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2]
-  //  If a list item is an array section, it must specify contiguous storage.
-  //
-  // For this restriction it is sufficient that we make sure only references
-  // to variables or fields and array expressions, and that no array sections
-  // exist except in the rightmost expression (unless they cover the whole
-  // dimension of the array). E.g. these would be invalid:
-  //
-  //   r.ArrS[3:5].Arr[6:7]
-  //
-  //   r.ArrS[3:5].x
-  //

[PATCH] D71524: [analyzer] Support tainted objects in GenericTaintChecker

2020-02-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a reviewer: steakhal.
Szelethus added a comment.
This revision now requires changes to proceed.

This patch is really cool, but I still feel anxious a bit about duplicating so 
much functionality, especially since we're working very hard to make 
`CallEvent` a widespread thing. @steakhal's patch D72035 
 already made some great progress in this 
direction, and should land before this one. @NoQ, do you agree that we should 
maybe stop for a bit before making the code a bit more consistent with the rest 
of the checkers?

I added @steakhal as reviewer if you don't mind.


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

https://reviews.llvm.org/D71524



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


[PATCH] D74131: [analyzer][taint] Add isTainted debug expression inspection check

2020-02-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a reviewer: boga95.
Szelethus added a comment.

In D74131#1884372 , @steakhal wrote:

> If this patch is good to go, could someone commit it?
>  I don't have commit access (yet).


I think you can apply for a commit access, you have a history of high quality 
patches!




Comment at: clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp:97
 .Case("clang_analyzer_express", &ExprInspectionChecker::analyzerExpress)
+.StartsWith("clang_analyzer_isTainted", 
&ExprInspectionChecker::analyzerIsTainted)
 .Default(nullptr);

xazax.hun wrote:
> I think a comment somewhere why/when do we check only the prefix would be 
> useful.
This isn't done?



Comment at: clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp:427-430
+  if (CE->getNumArgs() != 1) {
+reportBug("clang_analyzer_isTainted() requires exactly one argument", C);
+return;
+  }

Might as well create a test case for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74131



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


[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D74973#1889273 , @Szelethus wrote:

> FYI I've been seeing your patches to this checker and I will respond to them, 
> but I need to do some learning on my own before having the confidence to 
> accept or request changes. Working on it!


No worries, just take your time! :) In the meanwhile, I am trying to implement 
the "non-null" argument constraint based on these two patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74973



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


[PATCH] D75056: [ARM][AArch64] Default to -fno-common

2020-02-24 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer created this revision.
Herald added a subscriber: kristof.beyls.

This patch proposes to default to `-fno-common` for the Arm targets because 
this has performance and code-size benefits.

Additionally, GCC now also defaults to this, so we would be behaving the same 
as GCC:

  commit 6271dd984d7f920d4fb17ad37af6a1f8e6b796dc
  Author: Wilco Dijkstra 
  Date:   Wed Nov 20 16:29:23 2019 +
  PR85678: Change default to -fno-common
  GCC currently defaults to -fcommon.  As discussed in the PR, this is an 
ancient
  C feature which is not conforming with the latest C standards.  On many 
targets
  this means global variable accesses have a codesize and performance 
penalty.
  This applies to C code only, C++ code is not affected by -fcommon.  It is 
about
  time to change the default.


https://reviews.llvm.org/D75056

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/triple-arm-none.c


Index: clang/test/Driver/triple-arm-none.c
===
--- /dev/null
+++ clang/test/Driver/triple-arm-none.c
@@ -0,0 +1,38 @@
+// RUN: %clang --target=armv7-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A32LITTLE
+
+// RUN: %clang --target=armv7-arm-none-eabi -mbig-endian -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A32BIG
+// RUN: %clang --target=armebv7-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A32BIG
+
+// RUN: %clang --target=armv8a-arm-none-eabi -mthumb -### -c %s 2>&1 | \
+// RUN:  FileCheck %s --check-prefix=CHECK --check-prefix=T32LITTLE
+// RUN: %clang --target=thumbv8a-arm-none-eabi -### -c %s 2>&1  | \
+// RUN:   FileCheck %s --check-prefix=CHECK
+
+// RUN: %clang --target=armv8a-arm-none-eabi -mthumb -mbig-endian -### -c %s 
2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=T32BIG
+// RUN: %clang --target=thumbv8a-arm-none-eabi -mbig-endian -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK
+// RUN: %clang --target=thumbebv8a-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK
+
+// RUN: %clang --target=aarch64_be-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A64BIG
+
+// A32LITTLE: Target: armv7-arm-none-eabi
+// A64LITTLE: Target: aarch64-arm-none-eabi
+// A64BIG: Target: aarch64_be-arm-none-eabi
+
+// CHECK: "-cc1"
+// CHECK-NOT: "-no-integrated-as"
+
+// A32LITTLE: "-triple" "armv7-arm-none-eabi"
+// A32BIG: "-triple" "armebv7-arm-none-eabi"
+// T32LITTLE: "-triple" "thumbv8-arm-none-eabi"
+// T32BIG: "-triple" "thumbebv8-arm-none-eabi"
+// A64LITTLE: "-triple" "aarch64-arm-none-eabi"
+// A64BIG: "-triple" "aarch64_be-arm-none-eabi"
+
+// CHECK: "-fno-common"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1415,6 +1415,12 @@
   return true;
 return false;
 
+  case llvm::Triple::aarch64:
+  case llvm::Triple::aarch64_be:
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
   case llvm::Triple::xcore:
   case llvm::Triple::wasm32:
   case llvm::Triple::wasm64:


Index: clang/test/Driver/triple-arm-none.c
===
--- /dev/null
+++ clang/test/Driver/triple-arm-none.c
@@ -0,0 +1,38 @@
+// RUN: %clang --target=armv7-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A32LITTLE
+
+// RUN: %clang --target=armv7-arm-none-eabi -mbig-endian -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A32BIG
+// RUN: %clang --target=armebv7-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A32BIG
+
+// RUN: %clang --target=armv8a-arm-none-eabi -mthumb -### -c %s 2>&1 | \
+// RUN:  FileCheck %s --check-prefix=CHECK --check-prefix=T32LITTLE
+// RUN: %clang --target=thumbv8a-arm-none-eabi -### -c %s 2>&1  | \
+// RUN:   FileCheck %s --check-prefix=CHECK
+
+// RUN: %clang --target=armv8a-arm-none-eabi -mthumb -mbig-endian -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=T32BIG
+// RUN: %clang --target=thumbv8a-arm-none-eabi -mbig-endian -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK
+// RUN: %clang --target=thumbebv8a-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK
+
+// RUN: %clang --target=aarch64_be-arm-none-eabi -### -c %s 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK --check-prefix=A64BIG
+
+// A32LITTLE: Target: armv7-arm-none-eabi
+// A64LITTLE: Target: aarch64-arm-none-eabi
+// A64BIG: Target: aarch64_be-arm-none-eabi
+
+// CHECK: "-cc1"
+// CHECK-NOT: "-no-integrated-as"
+
+// A32LITTLE: "-triple" "a

[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-24 Thread Rong Xu via Phabricator via cfe-commits
xur added a comment.

Gentle ping. Is the newest patch ok?


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

https://reviews.llvm.org/D74878



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


[PATCH] D75057: Syndicate, test and fix base64 implementation

2020-02-24 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: jvikstrom, george.karpenkov.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, usaxena95, 
kadircet, arphaman, jkorous, mgorny.
Herald added projects: clang, Sanitizers, LLVM.

As an answer to https://github.com/llvm/llvm-project/issues/149, and to a 
comment in the code, syndicate base64 implementation between compiler-rt and 
clang-tools-extra


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75057

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  compiler-rt/lib/fuzzer/FuzzerUtil.cpp
  llvm/include/llvm/Support/Base64.h
  llvm/unittests/Support/Base64Test.cpp
  llvm/unittests/Support/CMakeLists.txt

Index: llvm/unittests/Support/CMakeLists.txt
===
--- llvm/unittests/Support/CMakeLists.txt
+++ llvm/unittests/Support/CMakeLists.txt
@@ -9,6 +9,7 @@
   AnnotationsTest.cpp
   ARMAttributeParser.cpp
   ArrayRecyclerTest.cpp
+  Base64Test.cpp
   BinaryStreamTest.cpp
   BlockFrequencyTest.cpp
   BranchProbabilityTest.cpp
Index: llvm/unittests/Support/Base64Test.cpp
===
--- /dev/null
+++ llvm/unittests/Support/Base64Test.cpp
@@ -0,0 +1,46 @@
+//===- llvm/unittest/Support/Base64.cpp - Base64 tests ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements unit tests for the Base64 functions.
+//
+//===--===//
+
+#include "llvm/Support/Base64.h"
+#include "llvm/ADT/StringRef.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+/// Tests an arbitrary set of bytes passed as \p Input.
+void TestBase64(StringRef Input, StringRef Final) {
+  auto Res = encodeBase64(Input);
+  EXPECT_EQ(Res, Final);
+}
+
+} // namespace
+
+TEST(Base64Test, Base64) {
+  // from: https://tools.ietf.org/html/rfc4648#section-10
+  TestBase64("", "");
+  TestBase64("f", "Zg==");
+  TestBase64("fo", "Zm8=");
+  TestBase64("foo", "Zm9v");
+  TestBase64("foob", "Zm9vYg==");
+  TestBase64("fooba", "Zm9vYmE=");
+  TestBase64("foobar", "Zm9vYmFy");
+
+  // Large test case
+  char LargeVector[] = {0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b,
+0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20, 0x66, 0x6f,
+0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70, 0x73, 0x20, 0x6f,
+0x76, 0x65, 0x72, 0x20, 0x31, 0x33, 0x20, 0x6c, 0x61,
+0x7a, 0x79, 0x20, 0x64, 0x6f, 0x67, 0x73, 0x2e};
+  TestBase64(LargeVector,
+ "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIDEzIGxhenkgZG9ncy4=");
+}
Index: llvm/include/llvm/Support/Base64.h
===
--- /dev/null
+++ llvm/include/llvm/Support/Base64.h
@@ -0,0 +1,54 @@
+//===--- Base64.h - Base64 Encoder/Decoder --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file provides generic base64 encoder/decoder.
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_BASE64_H
+#define LLVM_SUPPORT_BASE64_H
+
+#include 
+#include 
+
+namespace llvm {
+
+std::string encodeBase64(InputBytes const &Bytes) {
+  static const char Table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+  "abcdefghijklmnopqrstuvwxyz"
+  "0123456789+/";
+  std::string Buffer;
+  Buffer.resize(((Bytes.size() + 2) / 3) * 4);
+
+  size_t i = 0, j = 0;
+  for (size_t n = Bytes.size() / 3 * 3; i < n; i += 3, j += 4) {
+uint32_t x = (Bytes[i] << 16) | (Bytes[i + 1] << 8) | Bytes[i + 2];
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = Table[(x >> 6) & 63];
+Buffer[j + 3] = Table[x & 63];
+  }
+  if (i + 1 == Bytes.size()) {
+uint32_t x = (Bytes[i] << 16);
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = '=';
+Buffer[j + 3] = '=';
+  } else if (i + 2 == Bytes.size()) {
+uint32_t x = (Bytes[i] << 16) | (Bytes[i + 1] << 8);
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = Table[(x >> 6) & 63];
+Buffer[j + 3] = '=';
+  }
+  return Buffer;
+}
+
+} // end namespace llvm
+
+#endif
Index: compiler-rt/lib/fuzzer/FuzzerUtil.cpp
=

[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-24 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

Will this also give a warning when passing a .ll file to a release clang, 
without explicitly  passing the '-fdiscard-value-names' ? Is this what we want 
it to be ?


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

https://reviews.llvm.org/D74878



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


[PATCH] D75057: Syndicate, test and fix base64 implementation

2020-02-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri requested changes to this revision.
lebedev.ri added inline comments.
This revision now requires changes to proceed.



Comment at: compiler-rt/lib/fuzzer/FuzzerUtil.cpp:14-16
+
+#include "llvm/Support/Base64.h"
+

I don't believe we can do this. libfuzzer is acting as a sub-sub-project,
and i strongly believe it wants to shy away from using anything
other than it's own headers and standard c/c++ headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75057



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


[PATCH] D74470: Seperated DIBasicType DIFlags to DIBTFlags.

2020-02-24 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Thank you this looks very good! Just a few questions inline.




Comment at: llvm/lib/AsmParser/LLParser.cpp:4171
+template <>
+bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DIBTFlagField &Result) {
+

Chirag wrote:
> Chirag wrote:
> > Chirag wrote:
> > > aprantl wrote:
> > > > Could the bulk of the implementation of this function be shared with 
> > > > the function that parses DIFlag and DISPFlag?
> > > Does using macro to generate flag LLParser seems like a good idea? it can 
> > > be reused for other flags as well.
> > something like,
> > 
> > #define FLAG_FIELDS(MDNODE, FLAG_NAME)  
> >   \
> > struct DI##FLAG_NAME##Field : public MDFieldImpl 
> > {  \
> >   DI##FLAG_NAME##Field() : MDFieldImpl(MDNODE::FLAG_NAME##Zero) {}  
> >   \
> > };
> > 
> > FLAG_FIELDS(DINode, Flag)
> > FLAG_FIELDS(DIBasicType, BTFlag)
> > FLAG_FIELDS(DISubprogram, SPFlag)
> > 
> > 
> > #define FLAG_FIELDS_PARSER(MDNODE, FLAG_NAME)   
> >   \
> > template <> 
> >   \
> > bool LLParser::ParseMDField(LocTy Loc, StringRef Name,  
> >   \
> > DI##FLAG_NAME##Field &Result) { 
> >   \
> > 
> >   \
> >   auto parseFlag = [&](MDNODE::DI##FLAG_NAME##s &Val) { 
> >   \
> > if (Lex.getKind() == lltok::APSInt && !Lex.getAPSIntVal().isSigned()) { 
> >   \
> >   uint32_t TempVal = static_cast(Val);
> >   \
> >   bool Res = ParseUInt32(TempVal);  
> >   \
> >   Val = static_cast(TempVal); 
> >   \
> >   return Res;   
> >   \
> > }   
> >   \
> > 
> >   \
> > if (Lex.getKind() != lltok::DI##FLAG_NAME)  
> >   \
> >   return TokError("expected debug info flag");  
> >   \
> > 
> >   \
> > Val = MDNODE::getFlag(Lex.getStrVal()); 
> >   \
> > if (!Val)   
> >   \
> >   return TokError(Twine("invalid basicType debug info flag '") +
> >   \
> >   Lex.getStrVal() + "'");   
> >   \
> > Lex.Lex();  
> >   \
> > return false;   
> >   \
> >   };
> >   \
> > 
> >   \
> >   MDNODE::DI##FLAG_NAME##s Combined = MDNODE::FLAG_NAME##Zero;  
> >   \
> >   do {  
> >   \
> > MDNODE::DI##FLAG_NAME##s Val;   
> >   \
> > if (parseFlag(Val)) 
> >   \
> >   return true;  
> >   \
> > Combined |= Val;
> >   \
> >   } while (EatIfPresent(lltok::bar));   
> >   \
> > 
> >   \
> >   Result.assign(Combined);  
> >   \
> >   return false; 
> >   \
> > }
> > 
> > FLAG_FIELDS_PARSER(DINode, Flag)
> > FLAG_FIELDS_PARSER(DIBasicType, BTFlag)
> > FLAG_FIELDS_PARSER(DISubprogram, SPFlag)
> > 
> > 
> i will create a reusable function for flag parsing. 
Sharing the parsing code was not feasible?



Comment at: llvm/lib/Bitcode/Reader/MetadataLoader.cpp:1515
+// Some flags were moved from DIFlags to SPFlags
+DISubprogram::moveDItoSPFlags(Flags, SPFlags);
+

I believe this should only be called conditionally? Or specifically: What will 
happen when we reuse flag bits that are in the range of the old now freed-up 
DIFlags?



Comment at: llvm/lib/IR/AsmWriter.cpp:1721
 
+void MDFieldPrinter::printDIBTFlags(StringRef Name,
+DIBasicType::DIBTFlags Flags) {

Again, can this function share code with the printDISPFlags function?



Comment at: llvm/lib/IR/DebugInfoMetadata.cpp:366
+  switch (Flag) {
+// Appease a warning.
+#define HANDLE_DIBT

[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-02-24 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

LGTM




Comment at: llvm/unittests/IR/MetadataTest.cpp:2106
+  auto *N =
+  DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value);
   EXPECT_EQ(Tag, N->getTag());

For consistency, let's assign "false" to `bool Defaulted = false` and use that 
instead of hardcoding "false" here


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

https://reviews.llvm.org/D73462



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


[PATCH] D69560: [clang-tidy] Add 'cppcoreguidelines-avoid-adjacent-arguments-of-same-type' check

2020-02-24 Thread Whisperity via Phabricator via cfe-commits
whisperity marked an inline comment as done.
whisperity added a comment.

I'd rather not call them //false positive// because the definition of `false 
positive` is ugly and mushy with regards to this check. This check attempts to 
enforce an interface rule, whether you(r project) wants to adhere the rule is a 
concise decision. A type equivalence (or convertibility in case of the 
follow-up patch D75041  that considers 
implicit conversions) should be a "true positive" in every case, as an 
indicator of potentially bad design.

However, there's the question whether or not the similar argument-ness is 
intentional, i.e. a (from one PoV flawed) but deliberate design decision by the 
project. We've tested a few projects. The ugliest I've found is //OpenCV// 
where every variable of a function argument is either an `_InputArray` or an 
`_OutputArray`...

Another question is, how fragmented you want your type system to be...
I hope my research into this topic will be at least something fruitful. It's 
all about compromises, one end if using `any` for all your variables, the other 
extreme is having a specific type for every single occurrence (stuff like 
`fabs_return_t`, `create_schema_name_t` and stuff).

There's a similar patch D20689  but that uses 
names (and thus requires that arguments and parameters to be "named" in some 
way).




Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AdjacentArgumentsOfSameTypeCheck.cpp:474
+// Default to 3 so the users don't get a warning for every possible thing.
+static const unsigned DefaultMinLength = 3;
+

vingeldal wrote:
> Am I getting this right, is this the number of consecutive arguments of the 
> same type which is required for this check to print a diagnostic? If so: why 
> not set the default value to 2? -I think that's what a user who just read the 
> C++ Core Guidelines would expect.
Well, it is to reduce the number of nagging errors. Setting it to `2` would 
result in every "min" and "pow" and similar functions to match. It's a 
compromise.


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

https://reviews.llvm.org/D69560



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


[PATCH] D69560: [clang-tidy] Add 'cppcoreguidelines-avoid-adjacent-arguments-of-same-type' check

2020-02-24 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D74463#1888270 , @aaron.ballman 
wrote:

> I am also concerned about the false positives from this check because I don't 
> think there's going to be an easy heuristic for determining whether two 
> identifiers are "related" to one another.


I agree, and this is an unfortunate thing, but I do not think there //could// 
be a sensible heuristic here. Unless we somehow flesh out D20689 
 which uses name checks. (The two checks could 
actually complement each other - this one is for users who want to design their 
APIs defensively and want to see the changes during their code's evolution.)

In D74463#1888270 , @aaron.ballman 
wrote:

> There is no obvious way to silence any of the diagnostics generated as false 
> positives short of requiring a naming convention for users to follow, which 
> is not a particularly clean solution.


There is, you decide not to enable the checker?


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

https://reviews.llvm.org/D69560



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


[PATCH] D74760: [Analyzer] Fix for iterator modeling and checkers: handle negative numbers correctly

2020-02-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

This patch is a good testament to how well those debug functions turned out. 
LGTM.




Comment at: clang/lib/StaticAnalyzer/Checkers/Iterator.cpp:203
   auto &SVB = State->getStateManager().getSValBuilder();
+  auto &BVF = State->getStateManager().getBasicVals();
 

Don't use auto here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74760



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 246229.
martong added a comment.

Rebase on top of https://reviews.llvm.org/D74973


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/analyzer-enabled-checkers.c
  clang/test/Analysis/std-c-library-functions-arg-constraints-bug-path.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions.c

Index: clang/test/Analysis/std-c-library-functions.c
===
--- clang/test/Analysis/std-c-library-functions.c
+++ clang/test/Analysis/std-c-library-functions.c
@@ -1,8 +1,34 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple i686-unknown-linux \
+// RUN:   -verify
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple x86_64-unknown-linux \
+// RUN:   -verify
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple armv7-a15-linux \
+// RUN:   -verify
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple thumbv7-a15-linux \
+// RUN:   -verify
 
 void clang_analyzer_eval(int);
 
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -0,0 +1,44 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -triple x86_64-unknown-linux-gnu \
+// RUN:   -verify
+
+void clang_analyzer_eval(int);
+
+int glob;
+
+#define EOF -1
+
+int isalnum(int);
+
+void test_alnum_concrete(int v) {
+  int ret = isalnum(256); // expected-warning{{Function argument constraint is not satisfied}}
+  (void)ret;
+}
+
+void test_alnum_symbolic(int x) {
+  int ret = isalnum(x);
+  (void)ret;
+  clang_analyzer_eval(EOF <= x && x <= 255); // expected-warning{{TRUE}}
+}
+
+void test_alnum_symbolic2(int x) {
+  if (x > 255) {
+int ret = isalnum(x); // expected-warning{{Function argument constraint is not satisfied}}
+(void)ret;
+  }
+}
+
+void test_alnum_infeasible_path(int x, int y) {
+  int ret = isalnum(x);
+  y = 0;
+  clang_analyzer_eval(EOF <= x && x <= 255); // expected-warning{{TRUE}}
+
+  if (x > 255) // This path is no longer feasible.
+ret = x / y; // No warning here
+
+  ret = x / y; // expected-warning{{Division by zero}}
+}
Index: clang/test/Analysis/std-c-library-functions-arg-constraints-bug-path.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints-bug-path.c
@@ -0,0 +1,29 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -triple x86_64-unknown-linux-gnu \
+// RUN:   -analyzer-output=text \
+// RUN:   -verify
+
+void clang_analyzer_eval(i

[PATCH] D69662: [Checkers] Avoid using evalCall in StreamChecker.

2020-02-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.
Herald added a subscriber: martong.

In D69662#1744479 , @NoQ wrote:

> In D69662#1736601 , @balazske wrote:
>
> > Anyway the checks that do not use BindExpr (all except the open functions) 
> > could be moved into a PreCall or PostCall callback?
>
>
> Moving from evalCall to PreCall/PostCall has the additional effect of not 
> giving you control over invalidation of the heap (unless you do evalCall in a 
> checker, it ends up being the normal behavior of `conservativeEvalCall()` 
> most of the time). For that reason ideally every library function should be 
> evalCall'ed by a checker.
>
> Also if you're making updates to the program state that other checkers should 
> see immediately (say, writing out-parameter values into the Store or updating 
> a state trait that other checkers will read in the same callback), you should 
> either use evalCall for that, or make sure your dependencies are set up 
> correctly (@Szelethus, our callback invocation order is now affected by 
> checker dependencies, right?).


Sorry for the slack :)

One should never count on the invocation order of callback funcions in between 
checkers. In fact, I'm not too sure that my patches affect this, but I suspect 
that it does, as the container of choice for checker objects is `std::vector`.

> `checkArgNullStream()` should definitely be at PreCall.
> 
> `evalFseek()` doesn't have a `BindExpr` but it //should// have it; looks like 
> a bug. If you're evalCall-ing a non-void function you //must// bind a return 
> value (we should add an assertion for this; there's never a reason to bind an 
> `UnknownVal` in evalCall because there generally never is a good reason to 
> bind `UnknownVal` to anything because it shouldn't have been present in our 
> `SVal` hierarchy in the first place because conjuring a value is always 
> strictly better).




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69662



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


[PATCH] D75061: [RISCV] Fix sysroot tests without GCC on RISC-V hosts with GCC

2020-02-24 Thread Luís Marques via Phabricator via cfe-commits
luismarques created this revision.
luismarques added reviewers: edward-jones, lenary.
Herald added subscribers: cfe-commits, evandro, apazos, sameer.abuasal, pzheng, 
s.egerton, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, 
MartinMosbeck, rogfer01, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, 
sabuasal, simoncook, johnrusso, rbar, asb.
Herald added a project: clang.

D68391  added tests that check scenarios where 
no RISC-V GCC toolchain is supposed to be detected. When running the tests on 
RISC-V hosts the system's GCC toolchain will be detected, and the tests will 
fail. This patch adds a `--gcc-toolchain` option pointing to a path where no 
GCC toolchain is present, ensuring that the tests are run under the expected 
conditions, and therefore are able to pass in all test environments.

(I had also explored the option of checking if the found GCC toolchain actually 
matched the exact requested triple, but there seems to be no good way of doing 
that, and the test would still fail if such an exact match happened to be found 
anyway).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75061

Files:
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c


Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -19,6 +19,7 @@
 // RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
 // RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
 // RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
+// RUN:--gcc-toolchain=%T/testroot-riscv64-baremetal-nogcc/invalid \
 // RUN:-target riscv64-unknown-elf --rtlib=platform 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -19,6 +19,7 @@
 // RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld 
%T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
 // RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf 
%T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
 // RUN: %T/testroot-riscv32-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
+// RUN:--gcc-toolchain=%T/testroot-riscv32-baremetal-nogcc/invalid \
 // RUN:-target riscv32-unknown-elf --rtlib=platform 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 


Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -19,6 +19,7 @@
 // RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
 // RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf %T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
 // RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:--gcc-toolchain=%T/testroot-riscv64-baremetal-nogcc/invalid \
 // RUN:-target riscv64-unknown-elf --rtlib=platform 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -19,6 +19,7 @@
 // RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
 // RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf %T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
 // RUN: %T/testroot-riscv32-baremetal-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:--gcc-toolchain=%T/testroot-riscv32-baremetal-nogcc/invalid \
 // RUN:-target riscv32-unknown-elf --rtlib=platform 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71524: [analyzer] Support tainted objects in GenericTaintChecker

2020-02-24 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 marked 6 inline comments as done.
boga95 added a comment.

@steakhal's revision is on the top of this. Changing the order will only cause 
unnecessary work on both sides.




Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:103-132
   struct FunctionData {
 FunctionData() = delete;
 FunctionData(const FunctionData &) = default;
 FunctionData(FunctionData &&) = default;
 FunctionData &operator=(const FunctionData &) = delete;
 FunctionData &operator=(FunctionData &&) = delete;
 

Szelethus wrote:
> Szelethus wrote:
> > I know this isn't really relevant, but isn't this redundant with 
> > `CallDescription`?
> Ah, okay, so `CallDescription` doesn't really have the `FunctionDecl`, but 
> this still feels like a duplication of functionalities.
We have already thought about that and it is on our TODO list.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:139
 
+  /// Add taint sources for extraction operator on pre-visit.
+  bool addOverloadedOpPre(const CallExpr *CE, CheckerContext &C) const;

Szelethus wrote:
> Extraction operator? Is that a thing?
I can call it `operator>>` if you think that is better.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:202
   using ConfigDataMap =
   std::unordered_multimap>;
   using NameRuleMap = ConfigDataMap;

Szelethus wrote:
> http://llvm.org/docs/ProgrammersManual.html#other-map-like-container-options
> 
> > We never use hash_set and unordered_set because they are generally very 
> > expensive (each insertion requires a malloc) and very non-portable.
I didn't find any multimap among the alternatives. I think the performance 
won't be an issue here, because the elements are inserted at the beginning of 
the analysis if there is any. Otherwise, we are planning to replace it with 
CallDescriptionMap.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:268
CheckerContext &C) {
-  if (isTainted(State, E, C.getLocationContext()) || isStdin(E, C))
+  if (isTainted(State, E, C.getLocationContext()) || isStdin(E, C) ||
+  isStdstream(E, C))

xazax.hun wrote:
> If we consider `Stdin`  and `Stdstream` to be tainted does it make sense to 
> fold them into `isTainted` so we never miss checking for them?
Then we have to pass the `CheckerContext` to the `isTainted` functions. I think 
this function wraps it well.


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

https://reviews.llvm.org/D71524



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


[PATCH] D71524: [analyzer] Support tainted objects in GenericTaintChecker

2020-02-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D71524#1889566 , @boga95 wrote:

> @steakhal's revision is on the top of this. Changing the order will only 
> cause unnecessary work on both sides.


He recently rebased on top of master. I'm no fan of creating unnecessary work 
for either of you, and it might just be the case that my worry is greater then 
necessary. But for now, landing more patches with this infrastructure and 
having to painstakingly redo them all sounds like more work.

It'd be best to wait for @NoQ's feedback, after all, he did approve earlier 
patches. And again, sorry for not being available earlier.


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

https://reviews.llvm.org/D71524



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


[PATCH] D75006: [clang-format] Wrap lines for C# property accessors

2020-02-24 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 246235.
jbcoe added a comment.
This revision is now accepted and ready to land.

Simplify logic for merging property accessors


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

https://reviews.llvm.org/D75006

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -240,18 +240,12 @@
 
   verifyFormat("[TestMethod]\n"
"public string Host\n"
-   "{\n"
-   "set;\n"
-   "get;\n"
-   "}");
+   "{ set; get; }");
 
   verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server "
"listening on provided host\")]\n"
"public string Host\n"
-   "{\n"
-   "set;\n"
-   "get;\n"
-   "}");
+   "{ set; get; }");
 
   verifyFormat(
   "[DllImport(\"Hello\", EntryPoint = \"hello_world\")]\n"
@@ -554,5 +548,32 @@
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpPropertyAccessors) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat("int Value { get }", Style);
+  verifyFormat("int Value { get; }", Style);
+  verifyFormat("int Value { internal get; }", Style);
+  verifyFormat("int Value { get; } = 0", Style);
+  verifyFormat("int Value { set }", Style);
+  verifyFormat("int Value { set; }", Style);
+  verifyFormat("int Value { internal set; }", Style);
+  verifyFormat("int Value { set; } = 0", Style);
+  verifyFormat("int Value { get; set }", Style);
+  verifyFormat("int Value { set; get }", Style);
+  verifyFormat("int Value { get; private set; }", Style);
+  verifyFormat("int Value { get; set; }", Style);
+  verifyFormat("int Value { get; set; } = 0", Style);
+  verifyFormat("int Value { internal get; internal set; }", Style);
+
+  // Do not wrap expression body definitions.
+  verifyFormat(R"(//
+public string Name {
+  get => _name;
+  set => _name = value;
+})",
+   Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -292,6 +292,13 @@
   }
 }
 
+// Try to merge a CSharp property declaration like `{ get; private set }`.
+if (Style.isCSharp()) {
+  unsigned CSPA = tryMergeCSharpPropertyAccessor(I, E, Limit);
+  if (CSPA > 0)
+return CSPA;
+}
+
 // Try to merge a function block with left brace unwrapped
 if (TheLine->Last->is(TT_FunctionLBrace) &&
 TheLine->First != TheLine->Last) {
@@ -421,6 +428,64 @@
 return 0;
   }
 
+  // true for lines of the form [access-modifier] {get,set} [;]
+  bool isMergeablePropertyAccessor(const AnnotatedLine *Line) {
+auto *Tok = Line->First;
+if (!Tok)
+  return false;
+
+if (Tok->isOneOf(tok::kw_public, tok::kw_protected, tok::kw_private,
+ Keywords.kw_internal))
+  Tok = Tok->Next;
+
+if (!Tok || (Tok->TokenText != "get" && Tok->TokenText != "set"))
+  return false;
+
+if (!Tok->Next || Tok->Next->is(tok::semi))
+  return true;
+
+return false;
+  }
+
+  unsigned tryMergeCSharpPropertyAccessor(
+  SmallVectorImpl::const_iterator I,
+  SmallVectorImpl::const_iterator E, unsigned /*Limit*/) {
+
+auto CurrentLine = I;
+// Does line start with `{`
+if (!(*CurrentLine)->Last || (*CurrentLine)->Last->isNot(TT_FunctionLBrace))
+  return 0;
+++CurrentLine;
+
+unsigned MergedLines = 0;
+bool HasGetOrSet = false;
+while (CurrentLine != E) {
+  bool LineIsGetOrSet = isMergeablePropertyAccessor(*CurrentLine);
+  HasGetOrSet = HasGetOrSet || LineIsGetOrSet;
+  if (LineIsGetOrSet) {
+++CurrentLine;
+++MergedLines;
+continue;
+  }
+  auto *Tok = (*CurrentLine)->First;
+  if (Tok && Tok->is(tok::r_brace)) {
+++CurrentLine;
+++MergedLines;
+// See if the next line is a default value so that we can merge `{ get;
+// set } = 0`
+if (CurrentLine != E && (*CurrentLine)->First &&
+(*CurrentLine)->First->is(tok::equal)) {
+  ++MergedLines;
+}
+break;
+  }
+  // Not a '}' or a get/set line so do not merege lines.
+  return 0;
+}
+
+return HasGetOrSet ? MergedLines : 0;
+  }
+
   unsigned
   tryMergeSimplePPDirective(SmallVectorImpl::const_iterator I,
 SmallVectorImpl::const_iterator E,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bi

[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-24 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D74878#1889460 , @jeroen.dobbelaere 
wrote:

> Will this also give a warning when passing a .ll file to a release clang, 
> without explicitly  passing the '-fdiscard-value-names' ? Is this what we 
> want it to be ?


I think it does. @xur, we should probably explicitly check for 
`-fdiscard-value-names` before raising the warning (?)


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

https://reviews.llvm.org/D74878



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


[PATCH] D75063: [analyzer] StdLibraryFunctionsChecker: Add NotNull Arg Constraint

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: NoQ, Szelethus, balazske, gamesh411, 
baloghadamsoftware, steakhal.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
Herald added a project: clang.
martong added a parent revision: D73898: [analyzer] StdLibraryFunctionsChecker: 
Add argument constraints.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75063

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions.c

Index: clang/test/Analysis/std-c-library-functions.c
===
--- clang/test/Analysis/std-c-library-functions.c
+++ clang/test/Analysis/std-c-library-functions.c
@@ -78,10 +78,13 @@
 size_t fread(void *, size_t, size_t, FILE *);
 size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict);
 void test_fread_fwrite(FILE *fp, int *buf) {
+
   size_t x = fwrite(buf, sizeof(int), 10, fp);
   clang_analyzer_eval(x <= 10); // expected-warning{{TRUE}}
+
   size_t y = fread(buf, sizeof(int), 10, fp);
   clang_analyzer_eval(y <= 10); // expected-warning{{TRUE}}
+
   size_t z = fwrite(buf, sizeof(int), y, fp);
   clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
 }
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -42,3 +42,18 @@
 
   ret = x / y; // expected-warning{{Division by zero}}
 }
+
+typedef struct FILE FILE;
+typedef typeof(sizeof(int)) size_t;
+size_t fread(void *, size_t, size_t, FILE *);
+void test_notnull_concrete(FILE *fp) {
+  fread(0, sizeof(int), 10, fp); // expected-warning{{Function argument constraint is not satisfied}}
+}
+void test_notnull_symbolic(FILE *fp, int *buf) {
+  fread(buf, sizeof(int), 10, fp);
+  clang_analyzer_eval(buf != 0); // expected-warning{{TRUE}}
+}
+void test_notnull_symbolic2(FILE *fp, int *buf) {
+  if (!buf)
+fread(buf, sizeof(int), 10, fp); // expected-warning{{Function argument constraint is not satisfied}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -170,6 +170,28 @@
   const Summary &Summary) const override;
   };
 
+  class NotNullConstraint : public ValueConstraint {
+using ValueConstraint::ValueConstraint;
+bool CannotBeNull = true;
+
+  public:
+ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call,
+  const Summary &Summary) const override {
+  SVal V = getArgSVal(Call, getArgNo());
+  DefinedOrUnknownSVal L = V.castAs();
+  if (!L.getAs())
+return State;
+
+  return State->assume(L, CannotBeNull);
+}
+
+ValueConstraintPtr negate() const override {
+  NotNullConstraint tmp(*this);
+  tmp.CannotBeNull = !this->CannotBeNull;
+  return std::make_shared(tmp);
+}
+  };
+
   /// The complete list of constraints that defines a single branch.
   typedef std::vector ConstraintSet;
 
@@ -210,9 +232,6 @@
  "We should have had no significant void types in the spec");
   assert(T.isCanonical() &&
  "We should only have canonical types in the spec");
-  // FIXME: lift this assert (but not the ones above!)
-  assert(T->isIntegralOrEnumerationType() &&
- "We only support integral ranges in the spec");
 }
 
   public:
@@ -574,6 +593,9 @@
   const QualType LongTy = ACtx.LongTy;
   const QualType LongLongTy = ACtx.LongLongTy;
   const QualType SizeTy = ACtx.getSizeType();
+  const QualType VoidPtrTy = ACtx.VoidPtrTy; // void *T
+  const QualType ConstVoidPtrTy =
+  ACtx.getPointerType(ACtx.VoidTy.withConst()); // const void *T
 
   const RangeInt IntMax = BVF.getMaxValue(IntTy).getLimitedValue();
   const RangeInt LongMax = BVF.getMaxValue(LongTy).getLimitedValue();
@@ -638,6 +660,9 @@
 return IntRangeVector{std::pair{v, v}};
   };
   auto LessThanOrEq = BO_LE;
+  auto NotNull = [&](ArgNo ArgN) {
+return std::make_shared(ArgN);
+  };
 
   using RetType = QualType;
   // Templates for summaries that are reused by many functions.
@@ -653,11 +678,20 @@
ReturnValueCondition(WithinRange, Range(-1, Max))});
   };
   auto Fread = [&]() {
-return Summary(ArgTypes{Irrelevant, Irrelevant, SizeTy, Irrelevant},
+return Summary(ArgTypes{VoidPtrTy, Irrelevant, SizeTy, Irrelevant},
+   RetType{SizeTy}, NoEvalCall)
+.Case({
+ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+   

[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:93
+ValueConstraint(ArgNo ArgN) : ArgN(ArgN) {}
+virtual ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call,
+  const Summary &Summary) const = 0;

virtual dtor is missing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74973



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


[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@balazske See https://reviews.llvm.org/D75063 about the simple independent 
implementation of the NotNull constraint.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74973



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


[PATCH] D75057: Syndicate, test and fix base64 implementation

2020-02-24 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 246240.
serge-sans-paille added a comment.

Restore duplication, fix the bug in two separate locations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75057

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  compiler-rt/lib/fuzzer/FuzzerUtil.cpp
  llvm/include/llvm/Support/Base64.h
  llvm/unittests/Support/Base64Test.cpp
  llvm/unittests/Support/CMakeLists.txt

Index: llvm/unittests/Support/CMakeLists.txt
===
--- llvm/unittests/Support/CMakeLists.txt
+++ llvm/unittests/Support/CMakeLists.txt
@@ -9,6 +9,7 @@
   AnnotationsTest.cpp
   ARMAttributeParser.cpp
   ArrayRecyclerTest.cpp
+  Base64Test.cpp
   BinaryStreamTest.cpp
   BlockFrequencyTest.cpp
   BranchProbabilityTest.cpp
Index: llvm/unittests/Support/Base64Test.cpp
===
--- /dev/null
+++ llvm/unittests/Support/Base64Test.cpp
@@ -0,0 +1,46 @@
+//===- llvm/unittest/Support/Base64.cpp - Base64 tests ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements unit tests for the Base64 functions.
+//
+//===--===//
+
+#include "llvm/Support/Base64.h"
+#include "llvm/ADT/StringRef.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+/// Tests an arbitrary set of bytes passed as \p Input.
+void TestBase64(StringRef Input, StringRef Final) {
+  auto Res = encodeBase64(Input);
+  EXPECT_EQ(Res, Final);
+}
+
+} // namespace
+
+TEST(Base64Test, Base64) {
+  // from: https://tools.ietf.org/html/rfc4648#section-10
+  TestBase64("", "");
+  TestBase64("f", "Zg==");
+  TestBase64("fo", "Zm8=");
+  TestBase64("foo", "Zm9v");
+  TestBase64("foob", "Zm9vYg==");
+  TestBase64("fooba", "Zm9vYmE=");
+  TestBase64("foobar", "Zm9vYmFy");
+
+  // Large test case
+  char LargeVector[] = {0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b,
+0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20, 0x66, 0x6f,
+0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70, 0x73, 0x20, 0x6f,
+0x76, 0x65, 0x72, 0x20, 0x31, 0x33, 0x20, 0x6c, 0x61,
+0x7a, 0x79, 0x20, 0x64, 0x6f, 0x67, 0x73, 0x2e};
+  TestBase64(LargeVector,
+ "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIDEzIGxhenkgZG9ncy4=");
+}
Index: llvm/include/llvm/Support/Base64.h
===
--- /dev/null
+++ llvm/include/llvm/Support/Base64.h
@@ -0,0 +1,53 @@
+//===--- Base64.h - Base64 Encoder/Decoder --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file provides generic base64 encoder/decoder.
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_BASE64_H
+#define LLVM_SUPPORT_BASE64_H
+
+#include 
+
+namespace llvm {
+
+std::string encodeBase64(InputBytes const &Bytes) {
+  static const char Table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+  "abcdefghijklmnopqrstuvwxyz"
+  "0123456789+/";
+  std::string Buffer;
+  Buffer.resize(((Bytes.size() + 2) / 3) * 4);
+
+  size_t i = 0, j = 0;
+  for (size_t n = Bytes.size() / 3 * 3; i < n; i += 3, j += 4) {
+uint32_t x = (Bytes[i] << 16) | (Bytes[i + 1] << 8) | Bytes[i + 2];
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = Table[(x >> 6) & 63];
+Buffer[j + 3] = Table[x & 63];
+  }
+  if (i + 1 == Bytes.size()) {
+uint32_t x = (Bytes[i] << 16);
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = '=';
+Buffer[j + 3] = '=';
+  } else if (i + 2 == Bytes.size()) {
+uint32_t x = (Bytes[i] << 16) | (Bytes[i + 1] << 8);
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = Table[(x >> 6) & 63];
+Buffer[j + 3] = '=';
+  }
+  return Buffer;
+}
+
+} // end namespace llvm
+
+#endif
Index: compiler-rt/lib/fuzzer/FuzzerUtil.cpp
===
--- compiler-rt/lib/fuzzer/FuzzerUtil.cpp
+++ compiler-rt/lib/fuzzer/FuzzerUtil.cpp
@@ -151,32 +151,36 @@
   return true;
 }
 
+// Code duplicated (and tested) in llvm/i

[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-24 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:152
+break;
+  default:
+llvm_unreachable("Unknown RangeConstraint kind!");

This `default` branch is not needed here (actually gives a compiler warning 
too).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D75057: Syndicate, test and fix base64 implementation

2020-02-24 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 246243.
serge-sans-paille added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75057

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  compiler-rt/lib/fuzzer/FuzzerUtil.cpp
  llvm/include/llvm/Support/Base64.h
  llvm/unittests/Support/Base64Test.cpp
  llvm/unittests/Support/CMakeLists.txt

Index: llvm/unittests/Support/CMakeLists.txt
===
--- llvm/unittests/Support/CMakeLists.txt
+++ llvm/unittests/Support/CMakeLists.txt
@@ -9,6 +9,7 @@
   AnnotationsTest.cpp
   ARMAttributeParser.cpp
   ArrayRecyclerTest.cpp
+  Base64Test.cpp
   BinaryStreamTest.cpp
   BlockFrequencyTest.cpp
   BranchProbabilityTest.cpp
Index: llvm/unittests/Support/Base64Test.cpp
===
--- /dev/null
+++ llvm/unittests/Support/Base64Test.cpp
@@ -0,0 +1,46 @@
+//===- llvm/unittest/Support/Base64.cpp - Base64 tests ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements unit tests for the Base64 functions.
+//
+//===--===//
+
+#include "llvm/Support/Base64.h"
+#include "llvm/ADT/StringRef.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+/// Tests an arbitrary set of bytes passed as \p Input.
+void TestBase64(StringRef Input, StringRef Final) {
+  auto Res = encodeBase64(Input);
+  EXPECT_EQ(Res, Final);
+}
+
+} // namespace
+
+TEST(Base64Test, Base64) {
+  // from: https://tools.ietf.org/html/rfc4648#section-10
+  TestBase64("", "");
+  TestBase64("f", "Zg==");
+  TestBase64("fo", "Zm8=");
+  TestBase64("foo", "Zm9v");
+  TestBase64("foob", "Zm9vYg==");
+  TestBase64("fooba", "Zm9vYmE=");
+  TestBase64("foobar", "Zm9vYmFy");
+
+  // Large test case
+  char LargeVector[] = {0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b,
+0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20, 0x66, 0x6f,
+0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70, 0x73, 0x20, 0x6f,
+0x76, 0x65, 0x72, 0x20, 0x31, 0x33, 0x20, 0x6c, 0x61,
+0x7a, 0x79, 0x20, 0x64, 0x6f, 0x67, 0x73, 0x2e};
+  TestBase64(LargeVector,
+ "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIDEzIGxhenkgZG9ncy4=");
+}
Index: llvm/include/llvm/Support/Base64.h
===
--- /dev/null
+++ llvm/include/llvm/Support/Base64.h
@@ -0,0 +1,53 @@
+//===--- Base64.h - Base64 Encoder/Decoder --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file provides generic base64 encoder/decoder.
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_BASE64_H
+#define LLVM_SUPPORT_BASE64_H
+
+#include 
+
+namespace llvm {
+
+std::string encodeBase64(InputBytes const &Bytes) {
+  static const char Table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+  "abcdefghijklmnopqrstuvwxyz"
+  "0123456789+/";
+  std::string Buffer;
+  Buffer.resize(((Bytes.size() + 2) / 3) * 4);
+
+  size_t i = 0, j = 0;
+  for (size_t n = Bytes.size() / 3 * 3; i < n; i += 3, j += 4) {
+uint32_t x = (Bytes[i] << 16) | (Bytes[i + 1] << 8) | Bytes[i + 2];
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = Table[(x >> 6) & 63];
+Buffer[j + 3] = Table[x & 63];
+  }
+  if (i + 1 == Bytes.size()) {
+uint32_t x = (Bytes[i] << 16);
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = '=';
+Buffer[j + 3] = '=';
+  } else if (i + 2 == Bytes.size()) {
+uint32_t x = (Bytes[i] << 16) | (Bytes[i + 1] << 8);
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = Table[(x >> 6) & 63];
+Buffer[j + 3] = '=';
+  }
+  return Buffer;
+}
+
+} // end namespace llvm
+
+#endif
Index: compiler-rt/lib/fuzzer/FuzzerUtil.cpp
===
--- compiler-rt/lib/fuzzer/FuzzerUtil.cpp
+++ compiler-rt/lib/fuzzer/FuzzerUtil.cpp
@@ -151,32 +151,36 @@
   return true;
 }
 
+// Code duplicated (and tested) in llvm/include/llvm/Support/Base64.h
 std::string Base64(co

[PATCH] D75022: clang-format: Extend AllowShortLoopsOnASingleLine to do ... while loops.

2020-02-24 Thread Daan De Meyer via Phabricator via cfe-commits
DaanDeMeyer updated this revision to Diff 246244.
DaanDeMeyer added a comment.

Added unit tests and fixed the case where stuff follows the do statement (like 
a comment).


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

https://reviews.llvm.org/D75022

Files:
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -556,6 +556,17 @@
   verifyFormat("for (;;) /* still don't merge */\n"
"  continue;",
AllowsMergedLoops);
+  verifyFormat("do a++;\n"
+   "while (true);", 
+   AllowsMergedLoops);
+  verifyFormat("do /* Don't merge */\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do // Don't merge\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
 }
 
 TEST_F(FormatTest, FormatShortBracedStatements) {
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -404,7 +404,7 @@
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
 }
-if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while)) {
+if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do)) {
   return Style.AllowShortLoopsOnASingleLine
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
@@ -449,7 +449,10 @@
   return 0;
 Limit = limitConsideringMacros(I + 1, E, Limit);
 AnnotatedLine &Line = **I;
-if (Line.Last->isNot(tok::r_paren))
+if (!Line.First->is(tok::kw_do) && Line.Last->isNot(tok::r_paren))
+  return 0;
+// Only merge do while if do is the only statement on the line. 
+if (Line.First->is(tok::kw_do) && !Line.Last->is(tok::kw_do))
   return 0;
 if (1 + I[1]->Last->TotalLength > Limit)
   return 0;


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -556,6 +556,17 @@
   verifyFormat("for (;;) /* still don't merge */\n"
"  continue;",
AllowsMergedLoops);
+  verifyFormat("do a++;\n"
+   "while (true);", 
+   AllowsMergedLoops);
+  verifyFormat("do /* Don't merge */\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
+  verifyFormat("do // Don't merge\n"
+   "  a++;\n"
+   "while (true);",
+   AllowsMergedLoops);
 }
 
 TEST_F(FormatTest, FormatShortBracedStatements) {
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -404,7 +404,7 @@
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
 }
-if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while)) {
+if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do)) {
   return Style.AllowShortLoopsOnASingleLine
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
@@ -449,7 +449,10 @@
   return 0;
 Limit = limitConsideringMacros(I + 1, E, Limit);
 AnnotatedLine &Line = **I;
-if (Line.Last->isNot(tok::r_paren))
+if (!Line.First->is(tok::kw_do) && Line.Last->isNot(tok::r_paren))
+  return 0;
+// Only merge do while if do is the only statement on the line. 
+if (Line.First->is(tok::kw_do) && !Line.Last->is(tok::kw_do))
   return 0;
 if (1 + I[1]->Last->TotalLength > Limit)
   return 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75057: Syndicate, test and fix base64 implementation

2020-02-24 Thread serge via Phabricator via cfe-commits
serge-sans-paille removed a reviewer: lebedev.ri.
serge-sans-paille added a comment.

As a side note, pre-reserving the buffer size gives interesting speedup, see 
http://quick-bench.com/Lp6OwO2etW1YEmJayVWn3U8JDiY


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75057



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


[PATCH] D75057: Syndicate, test and fix base64 implementation

2020-02-24 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 246248.
serge-sans-paille added a comment.

Other copy/paste typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75057

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  compiler-rt/lib/fuzzer/FuzzerUtil.cpp
  llvm/include/llvm/Support/Base64.h
  llvm/unittests/Support/Base64Test.cpp
  llvm/unittests/Support/CMakeLists.txt

Index: llvm/unittests/Support/CMakeLists.txt
===
--- llvm/unittests/Support/CMakeLists.txt
+++ llvm/unittests/Support/CMakeLists.txt
@@ -9,6 +9,7 @@
   AnnotationsTest.cpp
   ARMAttributeParser.cpp
   ArrayRecyclerTest.cpp
+  Base64Test.cpp
   BinaryStreamTest.cpp
   BlockFrequencyTest.cpp
   BranchProbabilityTest.cpp
Index: llvm/unittests/Support/Base64Test.cpp
===
--- /dev/null
+++ llvm/unittests/Support/Base64Test.cpp
@@ -0,0 +1,46 @@
+//===- llvm/unittest/Support/Base64.cpp - Base64 tests ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements unit tests for the Base64 functions.
+//
+//===--===//
+
+#include "llvm/Support/Base64.h"
+#include "llvm/ADT/StringRef.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+/// Tests an arbitrary set of bytes passed as \p Input.
+void TestBase64(StringRef Input, StringRef Final) {
+  auto Res = encodeBase64(Input);
+  EXPECT_EQ(Res, Final);
+}
+
+} // namespace
+
+TEST(Base64Test, Base64) {
+  // from: https://tools.ietf.org/html/rfc4648#section-10
+  TestBase64("", "");
+  TestBase64("f", "Zg==");
+  TestBase64("fo", "Zm8=");
+  TestBase64("foo", "Zm9v");
+  TestBase64("foob", "Zm9vYg==");
+  TestBase64("fooba", "Zm9vYmE=");
+  TestBase64("foobar", "Zm9vYmFy");
+
+  // Large test case
+  char LargeVector[] = {0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b,
+0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20, 0x66, 0x6f,
+0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70, 0x73, 0x20, 0x6f,
+0x76, 0x65, 0x72, 0x20, 0x31, 0x33, 0x20, 0x6c, 0x61,
+0x7a, 0x79, 0x20, 0x64, 0x6f, 0x67, 0x73, 0x2e};
+  TestBase64(LargeVector,
+ "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIDEzIGxhenkgZG9ncy4=");
+}
Index: llvm/include/llvm/Support/Base64.h
===
--- /dev/null
+++ llvm/include/llvm/Support/Base64.h
@@ -0,0 +1,53 @@
+//===--- Base64.h - Base64 Encoder/Decoder --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file provides generic base64 encoder/decoder.
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_BASE64_H
+#define LLVM_SUPPORT_BASE64_H
+
+#include 
+
+namespace llvm {
+
+std::string encodeBase64(InputBytes const &Bytes) {
+  static const char Table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+  "abcdefghijklmnopqrstuvwxyz"
+  "0123456789+/";
+  std::string Buffer;
+  Buffer.resize(((Bytes.size() + 2) / 3) * 4);
+
+  size_t i = 0, j = 0;
+  for (size_t n = Bytes.size() / 3 * 3; i < n; i += 3, j += 4) {
+uint32_t x = (Bytes[i] << 16) | (Bytes[i + 1] << 8) | Bytes[i + 2];
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = Table[(x >> 6) & 63];
+Buffer[j + 3] = Table[x & 63];
+  }
+  if (i + 1 == Bytes.size()) {
+uint32_t x = (Bytes[i] << 16);
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = '=';
+Buffer[j + 3] = '=';
+  } else if (i + 2 == Bytes.size()) {
+uint32_t x = (Bytes[i] << 16) | (Bytes[i + 1] << 8);
+Buffer[j + 0] = Table[(x >> 18) & 63];
+Buffer[j + 1] = Table[(x >> 12) & 63];
+Buffer[j + 2] = Table[(x >> 6) & 63];
+Buffer[j + 3] = '=';
+  }
+  return Buffer;
+}
+
+} // end namespace llvm
+
+#endif
Index: compiler-rt/lib/fuzzer/FuzzerUtil.cpp
===
--- compiler-rt/lib/fuzzer/FuzzerUtil.cpp
+++ compiler-rt/lib/fuzzer/FuzzerUtil.cpp
@@ -151,32 +151,36 @@
   return true;
 }
 
+// Code duplicated (and tested) in llvm/include/llvm/Support/Base64.h
 std::st

  1   2   >