[PATCH] D33308: [analyzer]: Improve test handling with multiple constraint managers

2017-05-17 Thread Dominic Chen via Phabricator via cfe-commits
ddcc created this revision.

Modify the test infrastructure to properly handle tests that require z3, and 
merge together the output of all tests on success. This is required for 
https://reviews.llvm.org/D28954.


https://reviews.llvm.org/D33308

Files:
  test/Analysis/analyzer_test.py


Index: test/Analysis/analyzer_test.py
===
--- test/Analysis/analyzer_test.py
+++ test/Analysis/analyzer_test.py
@@ -5,24 +5,39 @@
 class AnalyzerTest(lit.formats.ShTest):
 
 def execute(self, test, litConfig):
-result = self.executeWithAnalyzeSubstitution(
-test, litConfig, '-analyzer-constraints=range')
+results = []
 
-if result.code == lit.Test.FAIL:
-return result
+# Parse any test requirements ('REQUIRES: ')
+saved_test = test
+lit.TestRunner.parseIntegratedTestScript(test)
+
+if 'z3' not in test.requires:
+results.append(self.executeWithAnalyzeSubstitution(
+saved_test, litConfig, '-analyzer-constraints=range'))
+
+if results[-1].code == lit.Test.FAIL:
+return results[-1]
 
 # If z3 backend available, add an additional run line for it
 if test.config.clang_staticanalyzer_z3 == '1':
-result = self.executeWithAnalyzeSubstitution(
-test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3')
+results.append(self.executeWithAnalyzeSubstitution(
+saved_test, litConfig, '-analyzer-constraints=z3 
-DANALYZER_CM_Z3'))
 
-return result
+# Combine all result outputs into the last element
+for x in results:
+if x != results[-1]:
+results[-1].output = x.output + results[-1].output
+
+if results:
+return results[-1]
+return lit.Test.Result(lit.Test.UNSUPPORTED,
+"Test requires the following unavailable features: z3")
 
 def executeWithAnalyzeSubstitution(self, test, litConfig, substitution):
 saved_substitutions = list(test.config.substitutions)
 test.config.substitutions.append(('%analyze', substitution))
 result = lit.TestRunner.executeShTest(test, litConfig,
-  self.execute_external)
+self.execute_external)
 test.config.substitutions = saved_substitutions
 
 return result


Index: test/Analysis/analyzer_test.py
===
--- test/Analysis/analyzer_test.py
+++ test/Analysis/analyzer_test.py
@@ -5,24 +5,39 @@
 class AnalyzerTest(lit.formats.ShTest):
 
 def execute(self, test, litConfig):
-result = self.executeWithAnalyzeSubstitution(
-test, litConfig, '-analyzer-constraints=range')
+results = []
 
-if result.code == lit.Test.FAIL:
-return result
+# Parse any test requirements ('REQUIRES: ')
+saved_test = test
+lit.TestRunner.parseIntegratedTestScript(test)
+
+if 'z3' not in test.requires:
+results.append(self.executeWithAnalyzeSubstitution(
+saved_test, litConfig, '-analyzer-constraints=range'))
+
+if results[-1].code == lit.Test.FAIL:
+return results[-1]
 
 # If z3 backend available, add an additional run line for it
 if test.config.clang_staticanalyzer_z3 == '1':
-result = self.executeWithAnalyzeSubstitution(
-test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3')
+results.append(self.executeWithAnalyzeSubstitution(
+saved_test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3'))
 
-return result
+# Combine all result outputs into the last element
+for x in results:
+if x != results[-1]:
+results[-1].output = x.output + results[-1].output
+
+if results:
+return results[-1]
+return lit.Test.Result(lit.Test.UNSUPPORTED,
+"Test requires the following unavailable features: z3")
 
 def executeWithAnalyzeSubstitution(self, test, litConfig, substitution):
 saved_substitutions = list(test.config.substitutions)
 test.config.substitutions.append(('%analyze', substitution))
 result = lit.TestRunner.executeShTest(test, litConfig,
-  self.execute_external)
+self.execute_external)
 test.config.substitutions = saved_substitutions
 
 return result
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28953: [analyzer] Eliminate analyzer limitations on symbolic constraint generation

2017-05-17 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

I've updated this revision to account for the recent SVal simplification commit 
by @NoQ, but now there is an exponential recursion problem that prevents 
testcase `PR24184.cpp` from terminating, due to an interaction between 
`Simplifier::VisitNonLocSymbolVal()` and `SValBuilder::makeSymExprValNN()`. I'm 
not quite sure what the best way to resolve this is; from some blind testing, I 
ended up needing to set `MaxComp` to `10` to force termination in a reasonable 
amount of time, but this restricts its usefulness for other constraints.


https://reviews.llvm.org/D28953



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


[PATCH] D33304: [clang-tidy] Add a new module Android and a new check for file descriptors.

2017-05-17 Thread Stephen Hines via Phabricator via cfe-commits
srhines added inline comments.



Comment at: clang-tidy/android/FileDescriptorCheck.cpp:65
+
+diag(FlagArg->getLocStart(), "open(), openat(), and open64() "
+  "must include O_CLOEXEC in their flags argument.")

Use "%0 " instead of the 3 function names, so that you can use << to print the 
name as part of the diagnostic. You can get the name by binding the 
FunctionDecl in the matcher you create (and then that lets you do 
"FD->getName()"). You can look at something like FasterStringFindCheck.cpp for 
a good example of this (search for "%0").



Comment at: clang-tidy/android/FileDescriptorCheck.cpp:76
+int64_t val = aPInt.getSExtValue();
+if((val & O_CLOEXEC) == 0)
+  return false;

Using O_CLOEXEC here is potentially a problem, since most of our compiles are 
cross-compiles. If O_CLOEXEC is different on the target platform than the host 
platform (where this code is being compiled), this check would fail. Perhaps we 
can get the value of O_CLOEXEC as defined for the translation unit (and if it 
isn't defined, that's already a pretty big indicator that any use of these 
functions will be wrong). Alternately, maybe just re-parsing for "O_CLOEXEC" is 
better.


Repository:
  rL LLVM

https://reviews.llvm.org/D33304



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


[PATCH] D28953: [analyzer] Eliminate analyzer limitations on symbolic constraint generation

2017-05-17 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 99392.
ddcc added a comment.

Address SVal simplification from https://reviews.llvm.org/D31886


https://reviews.llvm.org/D28953

Files:
  include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/bitwise-ops.c
  test/Analysis/bool-assignment.c
  test/Analysis/conditional-path-notes.c
  test/Analysis/explain-svals.cpp
  test/Analysis/plist-macros.cpp
  test/Analysis/range_casts.c
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -57,8 +57,7 @@
   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);
-  // FIXME: should be TRUE once symbol-symbol constraint support is improved.
-  clang_analyzer_eval(z <= y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
 }
 
 ssize_t getline(char **, size_t *, FILE *);
Index: test/Analysis/range_casts.c
===
--- test/Analysis/range_casts.c
+++ test/Analysis/range_casts.c
@@ -67,8 +67,8 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1 == 0) // Was not reached prior fix.
-clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (index - 1 == 0)
+clang_analyzer_warnIfReached(); // no-warning
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
 }
@@ -87,8 +87,8 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1L == 0L) // Was not reached prior fix.
-clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (index - 1L == 0L)
+clang_analyzer_warnIfReached(); // no-warning
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
 }
@@ -117,8 +117,8 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1UL == 0L) // Was not reached prior fix.
-clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (index - 1UL == 0L)
+clang_analyzer_warnIfReached(); // no-warning
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
 }
Index: test/Analysis/plist-macros.cpp
===
--- test/Analysis/plist-macros.cpp
+++ test/Analysis/plist-macros.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=ture %s -o %t.plist
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=true %s -o %t.plist
 // RUN: FileCheck --input-file=%t.plist %s
 
 
@@ -636,6 +636,69 @@
 // CHECK-NEXT: end
 // CHECK-NEXT:  
 // CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line36
+// CHECK-NEXT:   col7
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line36
+// CHECK-NEXT:  col7
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line36
+// CHECK-NEXT:  col25
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:

[PATCH] D32449: Modifying PthreadLockChecker.cpp to reduce false positives.

2017-05-17 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 updated this revision to Diff 99388.
malhar1995 marked an inline comment as done.
malhar1995 added a comment.

Cleaned up the previous patch. 
Added checking of LockState before initializing a mutex as well.
Added separate branches of execution for PthreadSemantics and XNUSemantics. 
Added assert in case of checkDeadSymbols as existence in DestroyRetVal ensures 
existence in LockMap.


Repository:
  rL LLVM

https://reviews.llvm.org/D32449

Files:
  .DS_Store
  lib/.DS_Store
  lib/StaticAnalyzer/.DS_Store
  lib/StaticAnalyzer/Checkers/.DS_Store
  lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  test/.DS_Store
  test/Analysis/.DS_Store

Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -25,30 +25,34 @@
 namespace {
 
 struct LockState {
-  enum Kind { Destroyed, Locked, Unlocked } K;
+  enum Kind { Destroyed, Locked, Unlocked, SchrodingerUntouched, SchrodingerUnlocked } K;
 
 private:
   LockState(Kind K) : K(K) {}
 
 public:
   static LockState getLocked() { return LockState(Locked); }
   static LockState getUnlocked() { return LockState(Unlocked); }
   static LockState getDestroyed() { return LockState(Destroyed); }
+  static LockState getSchrodingerUntouched() { return LockState(SchrodingerUntouched); }
+  static LockState getSchrodingerUnlocked() { return LockState(SchrodingerUnlocked); }
 
   bool operator==(const LockState ) const {
 return K == X.K;
   }
 
   bool isLocked() const { return K == Locked; }
   bool isUnlocked() const { return K == Unlocked; }
   bool isDestroyed() const { return K == Destroyed; }
+  bool isSchrodingerUntouched() const { return K == SchrodingerUntouched; }
+  bool isSchrodingerUnlocked() const { return K == SchrodingerUnlocked; }
 
   void Profile(llvm::FoldingSetNodeID ) const {
 ID.AddInteger(K);
   }
 };
 
-class PthreadLockChecker : public Checker< check::PostStmt > {
+class PthreadLockChecker : public Checker< check::PostStmt, check::DeadSymbols > {
   mutable std::unique_ptr BT_doublelock;
   mutable std::unique_ptr BT_doubleunlock;
   mutable std::unique_ptr BT_destroylock;
@@ -61,21 +65,24 @@
   };
 public:
   void checkPostStmt(const CallExpr *CE, CheckerContext ) const;
+  void checkDeadSymbols(SymbolReaper , CheckerContext ) const;
 
   void AcquireLock(CheckerContext , const CallExpr *CE, SVal lock,
bool isTryLock, enum LockingSemantics semantics) const;
 
   void ReleaseLock(CheckerContext , const CallExpr *CE, SVal lock) const;
-  void DestroyLock(CheckerContext , const CallExpr *CE, SVal Lock) const;
+  void DestroyLock(CheckerContext , const CallExpr *CE, SVal Lock, enum LockingSemantics semantics) const;
   void InitLock(CheckerContext , const CallExpr *CE, SVal Lock) const;
   void reportUseDestroyedBug(CheckerContext , const CallExpr *CE) const;
+  ProgramStateRef setAppropriateLockState(ProgramStateRef state, const MemRegion* lockR, const SymbolRef* sym, bool fromCheckDeadSymbols) const;
 };
 } // end anonymous namespace
 
 // GDM Entry for tracking lock state.
 REGISTER_LIST_WITH_PROGRAMSTATE(LockSet, const MemRegion *)
 
 REGISTER_MAP_WITH_PROGRAMSTATE(LockMap, const MemRegion *, LockState)
+REGISTER_MAP_WITH_PROGRAMSTATE(DestroyRetVal, const MemRegion *, SymbolRef)
 
 void PthreadLockChecker::checkPostStmt(const CallExpr *CE,
CheckerContext ) const {
@@ -113,22 +120,50 @@
FName == "lck_mtx_unlock" ||
FName == "lck_rw_done")
 ReleaseLock(C, CE, state->getSVal(CE->getArg(0), LCtx));
-  else if (FName == "pthread_mutex_destroy" ||
-   FName == "lck_mtx_destroy")
-DestroyLock(C, CE, state->getSVal(CE->getArg(0), LCtx));
+  else if (FName == "pthread_mutex_destroy")
+DestroyLock(C, CE, state->getSVal(CE->getArg(0), LCtx), PthreadSemantics);
+  else if (FName == "lck_mtx_destroy")
+DestroyLock(C, CE, state->getSVal(CE->getArg(0), LCtx), XNUSemantics);
   else if (FName == "pthread_mutex_init")
 InitLock(C, CE, state->getSVal(CE->getArg(0), LCtx));
 }
 
+ProgramStateRef PthreadLockChecker::setAppropriateLockState(ProgramStateRef state, const MemRegion* lockR, const SymbolRef* sym, bool fromCheckDeadSymbols) const {
+  const LockState* lstate = state->get(lockR);
+  // Existence in DestroyRetVal ensures existence in LockMap.
+  if(fromCheckDeadSymbols)
+assert(lstate);
+  else{
+if(!lstate)
+  return state;
+  }
+  ConstraintManager  = state->getConstraintManager();
+  ConditionTruthVal retZero = CMgr.isNull(state, *sym);
+  if(retZero.isConstrainedFalse()){
+if(lstate->isSchrodingerUntouched())
+  state = state->remove(lockR);
+else if(lstate->isSchrodingerUnlocked())
+  state = state->set(lockR, LockState::getUnlocked());
+  }
+  else{
+if(lstate->isSchrodingerUntouched() || 

r303325 - Fix an assertion failure in FormatASTNodeDiagnosticArgument.

2017-05-17 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed May 17 22:02:15 2017
New Revision: 303325

URL: http://llvm.org/viewvc/llvm-project?rev=303325=rev
Log:
Fix an assertion failure in FormatASTNodeDiagnosticArgument.

Summary:
The test being added in this patch used to cause an assertion failure:

/build/./bin/clang -cc1 -internal-isystem /build/lib/clang/5.0.0/include 
-nostdsysteminc -verify -fsyntax-only -std=c++11 -Wshadow-all 
/src/tools/clang/test/SemaCXX/warn-shadow.cpp
--
Exit Code: 134

Command Output (stderr):
--
clang: /src/tools/clang/lib/AST/ASTDiagnostic.cpp:424: void 
clang::FormatASTNodeDiagnosticArgument(DiagnosticsEngine::ArgumentKind, 
intptr_t, llvm::StringRef, llvm::StringRef, 
ArrayRef, SmallVectorImpl &, void *, 
ArrayRef): Assertion `isa(DC) && "Expected a NamedDecl"' 
failed.
#0 0x01c7a1b4 PrintStackTraceSignalHandler(void*) 
(/build/./bin/clang+0x1c7a1b4)
#1 0x01c7a4e6 SignalHandler(int) (/build/./bin/clang+0x1c7a4e6)
#2 0x7f30880078d0 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0xf8d0)
#3 0x7f3087054067 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35067)
#4 0x7f3087055448 abort (/lib/x86_64-linux-gnu/libc.so.6+0x36448)
#5 0x7f308704d266 (/lib/x86_64-linux-gnu/libc.so.6+0x2e266)
#6 0x7f308704d312 (/lib/x86_64-linux-gnu/libc.so.6+0x2e312)
#7 0x035b7f22 
clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind, 
long, llvm::StringRef, llvm::StringRef, 
llvm::ArrayRef >, 
llvm::SmallVectorImpl&, void*, llvm::ArrayRef) (/build/
./bin/clang+0x35b7f22)
#8 0x01ddbae4 clang::Diagnostic::FormatDiagnostic(char const*, char 
const*, llvm::SmallVectorImpl&) const (/build/./bin/clang+0x1ddbae4)
#9 0x01ddb323 clang::Diagnostic::FormatDiagnostic(char const*, char 
const*, llvm::SmallVectorImpl&) const (/build/./bin/clang+0x1ddb323)
#10 0x022878a4 
clang::TextDiagnosticBuffer::HandleDiagnostic(clang::DiagnosticsEngine::Level, 
clang::Diagnostic const&) (/build/./bin/clang+0x22878a4)
#11 0x01ddf387 
clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const 
(/build/./bin/clang+0x1ddf387)
#12 0x01dd9dea clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) 
(/build/./bin/clang+0x1dd9dea)
#13 0x02cad00c clang::Sema::EmitCurrentDiagnostic(unsigned int) 
(/build/./bin/clang+0x2cad00c)
#14 0x02d91cd2 clang::Sema::CheckShadow(clang::NamedDecl*, 
clang::NamedDecl*, clang::LookupResult const&) (/build/./bin/clang+0x2d91cd2)

Stack dump:
0.  Program arguments: /build/./bin/clang -cc1 -internal-isystem 
/build/lib/clang/5.0.0/include -nostdsysteminc -verify -fsyntax-only -std=c++11 
-Wshadow-all /src/tools/clang/test/SemaCXX/warn-shadow.cpp
1.  /src/tools/clang/test/SemaCXX/warn-shadow.cpp:214:23: current parser 
token ';'
2.  /src/tools/clang/test/SemaCXX/warn-shadow.cpp:213:26: parsing function 
body 'handleLinkageSpec'
3.  /src/tools/clang/test/SemaCXX/warn-shadow.cpp:213:26: in compound 
statement ('{}')
/build/tools/clang/test/SemaCXX/Output/warn-shadow.cpp.script: line 1: 15595 
Aborted (core dumped) /build/./bin/clang -cc1 -internal-isystem 
/build/lib/clang/5.0.0/include -nostdsysteminc -verify -fsyntax-only -std=c++11 
-Wshadow-all /src/tools/clang/test/SemaCXX/warn-shadow.cpp

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: krytarowski, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-shadow.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=303325=303324=303325=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 17 22:02:15 2017
@@ -6935,7 +6935,7 @@ void Sema::CheckShadow(NamedDecl *D, Nam
 }
 }
 
-  DeclContext *OldDC = ShadowedDecl->getDeclContext();
+  DeclContext *OldDC = ShadowedDecl->getDeclContext()->getRedeclContext();
 
   unsigned WarningDiag = diag::warn_decl_shadow;
   SourceLocation CaptureLoc;

Modified: cfe/trunk/test/SemaCXX/warn-shadow.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-shadow.cpp?rev=303325=303324=303325=diff
==
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp Wed May 17 22:02:15 2017
@@ -206,3 +206,10 @@ void avoidWarningWhenRedefining(int b) {
 }
 
 }
+
+extern "C" {
+typedef int externC; // expected-note {{previous declaration is here}}
+}
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in 
the global namespace}}
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D33207: Fix an assertion failure in FormatASTNodeDiagnosticArgument.

2017-05-17 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303325: Fix an assertion failure in 
FormatASTNodeDiagnosticArgument. (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D33207?vs=99112=99386#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33207

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/warn-shadow.cpp


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6935,7 +6935,7 @@
 }
 }
 
-  DeclContext *OldDC = ShadowedDecl->getDeclContext();
+  DeclContext *OldDC = ShadowedDecl->getDeclContext()->getRedeclContext();
 
   unsigned WarningDiag = diag::warn_decl_shadow;
   SourceLocation CaptureLoc;
Index: cfe/trunk/test/SemaCXX/warn-shadow.cpp
===
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp
@@ -206,3 +206,10 @@
 }
 
 }
+
+extern "C" {
+typedef int externC; // expected-note {{previous declaration is here}}
+}
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in 
the global namespace}}
+}


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6935,7 +6935,7 @@
 }
 }
 
-  DeclContext *OldDC = ShadowedDecl->getDeclContext();
+  DeclContext *OldDC = ShadowedDecl->getDeclContext()->getRedeclContext();
 
   unsigned WarningDiag = diag::warn_decl_shadow;
   SourceLocation CaptureLoc;
Index: cfe/trunk/test/SemaCXX/warn-shadow.cpp
===
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp
@@ -206,3 +206,10 @@
 }
 
 }
+
+extern "C" {
+typedef int externC; // expected-note {{previous declaration is here}}
+}
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in the global namespace}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r302966 - Remove unused tracking of owning module for MacroInfo objects.

2017-05-17 Thread Jordan Rose via cfe-commits
Thanks, this is helpful!


> On May 16, 2017, at 12:26, Richard Smith  wrote:
> 
> On 15 May 2017 at 10:28, Jordan Rose via cfe-commits 
> > wrote:
> Hi, Richard. Swift was using this information in order to put imported macros 
> in a particular context. It wouldn't surprise me to hear that we were doing 
> it wrong, and that there's a better way to go from a macro back to a module, 
> but is there a recommended replacement?
> 
> The recommended way to connect macros to modules is via the ModuleMacro 
> objects, which represent a macro exported from a module. You can query the 
> exported macro for a (module, identifier) pair with 
> Preprocessor::getModuleMacro, or walk the ModuleMacro graph for an identifier 
> by starting from Preprocessor::getLeafModuleMacros.
> 
> If you alternatively want to know the set of macros that would be visible 
> with a given set of imports, after setting up that state you can walk the 
> range produced by Preprocessor::macros(true) and query getActiveModuleMacros 
> on each MacroState.
> 
> If you want to know "what is the set of macros exported directly by this 
> module?", we don't have a prebuilt mechanism for that, since no in-tree 
> client wants that information, but one way would be to walk macros(true) and 
> query getModuleMacro(module, identifier) on each one.
> 
> Thanks,
> Jordan
> 
> 
> > On May 12, 2017, at 16:40, Richard Smith via cfe-commits 
> > > wrote:
> >
> > Author: rsmith
> > Date: Fri May 12 18:40:52 2017
> > New Revision: 302966
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=302966=rev 
> > 
> > Log:
> > Remove unused tracking of owning module for MacroInfo objects.
> >
> > Modified:
> >cfe/trunk/include/clang/Lex/MacroInfo.h
> >cfe/trunk/include/clang/Lex/Preprocessor.h
> >cfe/trunk/lib/Lex/MacroInfo.cpp
> >cfe/trunk/lib/Lex/PPDirectives.cpp
> >cfe/trunk/lib/Lex/Preprocessor.cpp
> >cfe/trunk/lib/Serialization/ASTReader.cpp
> >cfe/trunk/lib/Serialization/ASTWriter.cpp
> >
> > Modified: cfe/trunk/include/clang/Lex/MacroInfo.h
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=302966=302965=302966=diff
> >  
> > 
> > ==
> > --- cfe/trunk/include/clang/Lex/MacroInfo.h (original)
> > +++ cfe/trunk/include/clang/Lex/MacroInfo.h Fri May 12 18:40:52 2017
> > @@ -105,9 +105,6 @@ class MacroInfo {
> >   /// \brief Must warn if the macro is unused at the end of translation 
> > unit.
> >   bool IsWarnIfUnused : 1;
> >
> > -  /// \brief Whether this macro info was loaded from an AST file.
> > -  bool FromASTFile : 1;
> > -
> >   /// \brief Whether this macro was used as header guard.
> >   bool UsedForHeaderGuard : 1;
> >
> > @@ -264,34 +261,16 @@ public:
> > IsDisabled = true;
> >   }
> >
> > -  /// \brief Determine whether this macro info came from an AST file (such 
> > as
> > -  /// a precompiled header or module) rather than having been parsed.
> > -  bool isFromASTFile() const { return FromASTFile; }
> > -
> >   /// \brief Determine whether this macro was used for a header guard.
> >   bool isUsedForHeaderGuard() const { return UsedForHeaderGuard; }
> >
> >   void setUsedForHeaderGuard(bool Val) { UsedForHeaderGuard = Val; }
> >
> > -  /// \brief Retrieve the global ID of the module that owns this particular
> > -  /// macro info.
> > -  unsigned getOwningModuleID() const {
> > -if (isFromASTFile())
> > -  return *(const unsigned *)(this + 1);
> > -
> > -return 0;
> > -  }
> > -
> >   void dump() const;
> >
> > private:
> >   unsigned getDefinitionLengthSlow(const SourceManager ) const;
> >
> > -  void setOwningModuleID(unsigned ID) {
> > -assert(isFromASTFile());
> > -*(unsigned *)(this + 1) = ID;
> > -  }
> > -
> >   friend class Preprocessor;
> > };
> >
> >
> > Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=302966=302965=302966=diff
> >  
> > 
> > ==
> > --- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
> > +++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri May 12 18:40:52 2017
> > @@ -644,14 +644,6 @@ class Preprocessor {
> >   /// of that list.
> >   MacroInfoChain *MIChainHead;
> >
> > -  struct DeserializedMacroInfoChain {
> > -MacroInfo MI;
> > -unsigned OwningModuleID; // MUST be immediately after the MacroInfo 
> > object
> > - // so it can be 

r303322 - [modules] Switch from inferring owning modules based on source location to

2017-05-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed May 17 21:29:20 2017
New Revision: 303322

URL: http://llvm.org/viewvc/llvm-project?rev=303322=rev
Log:
[modules] Switch from inferring owning modules based on source location to
inferring based on the current module at the point of creation.

This should result in no functional change except when building a preprocessed
module (or more generally when using #pragma clang module begin/end to switch
module in the middle of a file), in which case it allows us to correctly track
the owning module for declarations. We can't map from FileID to module in the
preprocessed module case, since all modules would have the same FileID.

There are still a couple of remaining places that try to infer a module from a
source location; I'll clean those up in follow-up changes.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/preprocess-module.cpp
cfe/trunk/test/SemaCXX/modules-ts.cppm

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=303322=303321=303322=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed May 17 21:29:20 2017
@@ -935,7 +935,7 @@ public:
 
   /// \brief Get the additional modules in which the definition \p Def has
   /// been merged.
-  ArrayRef getModulesWithMergedDefinition(NamedDecl *Def) {
+  ArrayRef getModulesWithMergedDefinition(const NamedDecl *Def) {
 auto MergedIt = MergedDefModules.find(Def);
 if (MergedIt == MergedDefModules.end())
   return None;

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=303322=303321=303322=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed May 17 21:29:20 2017
@@ -332,15 +332,15 @@ private:
   bool AccessDeclContextSanity() const;
 
 protected:
-
   Decl(Kind DK, DeclContext *DC, SourceLocation L)
-: NextInContextAndBits(), DeclCtx(DC),
-  Loc(L), DeclKind(DK), InvalidDecl(0),
-  HasAttrs(false), Implicit(false), Used(false), Referenced(false),
-  Access(AS_none), FromASTFile(0), Hidden(DC && cast(DC)->Hidden),
-  IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
-  CacheValidAndLinkage(0)
-  {
+  : NextInContextAndBits(), DeclCtx(DC), Loc(L), DeclKind(DK),
+InvalidDecl(0), HasAttrs(false), Implicit(false), Used(false),
+Referenced(false), Access(AS_none), FromASTFile(0),
+Hidden(DC && cast(DC)->Hidden &&
+   (!cast(DC)->isFromASTFile() ||
+hasLocalOwningModuleStorage())),
+IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
+CacheValidAndLinkage(0) {
 if (StatisticsEnabled) add(DK);
   }
 
@@ -698,6 +698,9 @@ public:
   Module *getLocalOwningModule() const {
 if (isFromASTFile() || !Hidden)
   return nullptr;
+
+assert(hasLocalOwningModuleStorage() &&
+   "hidden local decl but no local module storage");
 return reinterpret_cast(this)[-1];
   }
   void setLocalOwningModule(Module *M) {

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=303322=303321=303322=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Wed May 17 21:29:20 2017
@@ -168,7 +168,7 @@ public:
 
   /// Do we need to track the owning module for a local declaration?
   bool trackLocalOwningModule() const {
-return ModulesLocalVisibility;
+return isCompilingModule() || ModulesLocalVisibility || ModulesTS;
   }
 
   bool isSignedOverflowDefined() const {

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303322=303321=303322=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed May 17 21:29:20 2017
@@ -1507,6 +1507,12 @@ public:
   hasVisibleDefaultArgument(const NamedDecl *D,
 llvm::SmallVectorImpl *Modules = 
nullptr);
 
+  /// Determine if there is a 

[clang-tools-extra] r303321 - [clang-tidy] Optimize GlobList::contains

2017-05-17 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed May 17 20:13:51 2017
New Revision: 303321

URL: http://llvm.org/viewvc/llvm-project?rev=303321=rev
Log:
[clang-tidy] Optimize GlobList::contains

With large lists of checks and large number of warnings GlobList::contains
starts being ridiculously CPU hungry, since it runs regexp match per glob.
Caching results of glob matching in a StringMap significantly speeds up check
filtering even for small GlobLists.

/tmp/q.cc:

void f() {
  int I;
  {int I;}
  {int I;}
  {int I;}
  ... // 200k times
}

Before the patch:

GlobList with 2 entries:
  $ time clang-tidy-old -checks=-*,modernize-use-override /tmp/q.cc -- -Wshadow
  20 warnings generated.
  Suppressed 20 warnings (20 with check filters).

  real0m3.826s
  user0m3.176s
  sys 0m0.504s

GlobList with 28 entries:
  $ time clang-tidy-old 
-checks=-*,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,modernize-use-override
 /tmp/q.cc -- -Wshadow
  20 warnings generated.
  Suppressed 20 warnings (20 with check filters).

  real0m5.000s
  user0m4.744s
  sys 0m0.060s

GlobList with 158 entries:
  $ time clang-tidy-old 
-checks=-*,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,modernize-use-override
 /tmp/q.cc -- -Wshadow
  20 warnings generated.
  Suppressed 20 warnings (20 with check filters).

  real0m13.920s
  user0m13.636s
  sys 0m0.104s

With the patch runtime is practically independent from the length of the 
GlobList:
  $ time clang-tidy-new 
-checks=-*,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,modernize-use-override
 /tmp/q.cc -- -Wshadow
  20 warnings generated.
  Suppressed 20 warnings (20 with check filters).

  real0m2.300s
  user0m2.104s
  sys 0m0.044s

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=303321=303320=303321=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Wed May 
17 20:13:51 2017
@@ -158,6 +158,26 @@ bool GlobList::contains(StringRef S, boo
   return Contains;
 }
 
+class ClangTidyContext::CachedGlobList {
+public:
+  CachedGlobList(StringRef Globs) : Globs(Globs) {}
+
+  bool contains(StringRef S) {
+switch (auto  = Cache[S]) {
+  case Yes: return true;
+  case No: return false;
+  case None:
+Result = Globs.contains(S) ? Yes : No;
+return Result == Yes;
+}
+  }
+
+private:
+  GlobList Globs;
+  enum Tristate { None, Yes, No };
+  llvm::StringMap Cache;
+};
+
 ClangTidyContext::ClangTidyContext(
 std::unique_ptr OptionsProvider)
 : DiagEngine(nullptr), OptionsProvider(std::move(OptionsProvider)),
@@ -167,6 +187,8 @@ ClangTidyContext::ClangTidyContext(
   setCurrentFile("");
 }
 
+ClangTidyContext::~ClangTidyContext() = default;
+
 DiagnosticBuilder ClangTidyContext::diag(
 StringRef CheckName, SourceLocation Loc, StringRef Description,
 DiagnosticIDs::Level Level /* = DiagnosticIDs::Warning*/) {
@@ -188,8 +210,9 @@ void ClangTidyContext::setSourceManager(
 void ClangTidyContext::setCurrentFile(StringRef File) {
   CurrentFile = File;
   CurrentOptions = getOptionsForFile(CurrentFile);
-  CheckFilter.reset(new GlobList(*getOptions().Checks));
-  WarningAsErrorFilter.reset(new GlobList(*getOptions().WarningsAsErrors));
+  CheckFilter = llvm::make_unique(*getOptions().Checks);
+  WarningAsErrorFilter =
+  llvm::make_unique(*getOptions().WarningsAsErrors);
 }
 
 void ClangTidyContext::setASTContext(ASTContext *Context) {
@@ -243,9 +266,9 @@ ClangTidyDiagnosticConsumer::ClangTidyDi
   LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
   LastErrorWasIgnored(false) {
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  Diags.reset(new DiagnosticsEngine(
+  Diags = llvm::make_unique(
   IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, this,
-  /*ShouldOwnClient=*/false));
+  /*ShouldOwnClient=*/false);
   Context.setDiagnosticsEngine(Diags.get());
 }
 
@@ -461,8 +484,8 @@ void ClangTidyDiagnosticConsumer::checkF
 
 

r303320 - [Statistics] Use the new Statistic::updateMax to atomically calculate a maximum value statistic.

2017-05-17 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed May 17 20:11:52 2017
New Revision: 303320

URL: http://llvm.org/viewvc/llvm-project?rev=303320=rev
Log:
[Statistics] Use the new Statistic::updateMax to atomically calculate a maximum 
value statistic.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=303320=303319=303320=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Wed May 17 20:11:52 2017
@@ -3448,14 +3448,12 @@ void BugReporter::FlushReport(BugReport
 // the BugReporterVisitors may mark this bug as a false positive.
 assert(!bugReports.empty());
 
-MaxBugClassSize =
-std::max(bugReports.size(), static_cast(MaxBugClassSize));
+MaxBugClassSize.updateMax(bugReports.size());
 
 if (!generatePathDiagnostic(*D.get(), PD, bugReports))
   return;
 
-MaxValidBugClassSize =
-std::max(bugReports.size(), static_cast(MaxValidBugClassSize));
+MaxValidBugClassSize.updateMax(bugReports.size());
 
 // Examine the report and see if the last piece is in a header. Reset the
 // report location to the last piece in the main source file.

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=303320=303319=303320=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Wed May 17 
20:11:52 2017
@@ -674,10 +674,8 @@ void AnalysisConsumer::HandleCode(Decl *
 
   DisplayFunction(D, Mode, IMode);
   CFG *DeclCFG = Mgr->getCFG(D);
-  if (DeclCFG) {
-unsigned CFGSize = DeclCFG->size();
-MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize;
-  }
+  if (DeclCFG)
+MaxCFGSize.updateMax(DeclCFG->size());
 
   BugReporter BR(*Mgr);
 


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


[PATCH] D33304: [clang-tidy] Add a new module Android and a new check for file descriptors.

2017-05-17 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please run clang-format over your code.

Please add documentation and mention this check in docs/ReleaseNotes.rst (in 
alphabetical order).


https://reviews.llvm.org/D33304



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


[PATCH] D33207: Fix an assertion failure in FormatASTNodeDiagnosticArgument.

2017-05-17 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


https://reviews.llvm.org/D33207



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


[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

2017-05-17 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.
Herald added a subscriber: krytarowski.

Check pointer arithmetic for overflow.

For some more background on this check, see:

  https://wdtz.org/catching-pointer-overflow-bugs.html
  https://reviews.llvm.org/D20322

Patch by Will Dietz and John Regehr!

This version of the patch is different from the original in a few ways:

- Incorporates feedback from @rsmith.
- It does some constant-folding to reduce instrumentation.
- The `ValidOffset' condition is inverted (same rationale).
- CGExprCXX is left untouched (same rationale, and also: I'm not sure that 
inserting checks here, or in CGClass, would catch many bugs).

Possible future directions for this check:

- Introduce CGF.EmitCheckedStructGEP, to detect overflows when accessing 
structures.

Testing: Apart from the added lit test, I ran check-llvm and check-clang
with a stage2, ubsan-instrumented clang. I found one overflow (see:
https://reviews.llvm.org/D33149).


https://reviews.llvm.org/D33305

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Basic/Sanitizers.def
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ubsan-pointer-overflow.m
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -3,27 +3,27 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-undefined-trap-on-error -fsanitize=undefined-trap %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
-// CHECK-UNDEFINED-TRAP: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute|function),?){18}"}}
-// CHECK-UNDEFINED-TRAP: "-fsanitize-trap=alignment,array-bounds,bool,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound"
-// CHECK-UNDEFINED-TRAP2: "-fsanitize-trap=alignment,array-bounds,bool,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift-base,shift-exponent,unreachable,vla-bound"
+// CHECK-UNDEFINED-TRAP: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute|function),?){19}"}}
+// CHECK-UNDEFINED-TRAP: "-fsanitize-trap=alignment,array-bounds,bool,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound"
+// CHECK-UNDEFINED-TRAP2: "-fsanitize-trap=alignment,array-bounds,bool,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,unreachable,vla-bound"
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED
-// CHECK-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|vptr|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){19}"}}
+// CHECK-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|vptr|object-size|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){20}"}}
 
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-DARWIN
-// CHECK-UNDEFINED-DARWIN: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){17}"}}
+// CHECK-UNDEFINED-DARWIN: 

[PATCH] D33304: [clang-tidy] Add a new module Android and a new check for file descriptors.

2017-05-17 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 99374.
yawanng added a comment.

Add unit test file.


https://reviews.llvm.org/D33304

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/FileDescriptorCheck.cpp
  clang-tidy/android/FileDescriptorCheck.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/android-file-descriptor.cpp
  unittests/clang-tidy/CMakeLists.txt

Index: unittests/clang-tidy/CMakeLists.txt
===
--- unittests/clang-tidy/CMakeLists.txt
+++ unittests/clang-tidy/CMakeLists.txt
@@ -26,6 +26,7 @@
   clangLex
   clangTidy
   clangTidyGoogleModule
+  clangTidyAndroidModule
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyReadabilityModule
Index: test/clang-tidy/android-file-descriptor.cpp
===
--- test/clang-tidy/android-file-descriptor.cpp
+++ test/clang-tidy/android-file-descriptor.cpp
@@ -0,0 +1,54 @@
+// RUN: %check_clang_tidy %s android-file-descriptor %t 
+
+#include 
+
+void a() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open(), openat(), and open64() must include O_CLOEXEC in their flags argument. [android-file-descriptor]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open(), openat(), and open64() must include O_CLOEXEC in their flags argument. [android-file-descriptor]
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void b() {
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open(), openat(), and open64() must include O_CLOEXEC in their flags argument. [android-file-descriptor]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open64("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open(), openat(), and open64() must include O_CLOEXEC in their flags argument. [android-file-descriptor]
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void c() {
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: open(), openat(), and open64() must include O_CLOEXEC in their flags argument. [android-file-descriptor]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  openat(0, "filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: open(), openat(), and open64() must include O_CLOEXEC in their flags argument. [android-file-descriptor]
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+namespace i {
+  int open(const char *pathname, int flags){ return 0; }
+  int open(const char *pathname, int flags, mode_t mode) { return 0; }
+  int open64(const char *pathname, int flags){ return 0; }
+  int open64(const char *pathname, int flags, mode_t mode) { return 0; }
+  int openat(int dirfd, const char *pathname, int flags) { return 0; }
+  int openat(int dirfd, const char *pathname, int flags, mode_t mode) { return 0; }
+}
+
+void d() {
+  i::open("filename", O_RDWR);
+  i::open64("filename", O_RDWR);
+  i::openat(0, "filename", O_RDWR);
+}
+
+void e() {
+  open("filename", O_CLOEXEC);
+  open("filename", O_RDWR | O_CLOEXEC);
+  open64("filename", O_CLOEXEC);
+  open64("filename", O_RDWR | O_CLOEXEC);
+  openat(0, "filename", O_CLOEXEC);
+  openat(0, "filename", O_RDWR | O_CLOEXEC);
+}
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -477,6 +477,11 @@
 static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
 GoogleModuleAnchorSource;
 
+// This anchor is used to force the linker to link the AndroidModule.
+extern volatile int AndroidModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
+AndroidModuleAnchorSource;
+
 // This anchor is used to force the linker to link the MiscModule.
 extern volatile int MiscModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
Index: clang-tidy/tool/CMakeLists.txt
===
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -17,6 +17,7 @@
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
   clangTidyGoogleModule
+  clangTidyAndroidModule
   clangTidyHICPPModule
   clangTidyLLVMModule
   clangTidyMiscModule
Index: clang-tidy/plugin/CMakeLists.txt
===
--- clang-tidy/plugin/CMakeLists.txt
+++ clang-tidy/plugin/CMakeLists.txt
@@ -12,6 +12,7 @@
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
   clangTidyGoogleModule
+  clangTidyAndroidModule
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyModernizeModule
Index: clang-tidy/android/FileDescriptorCheck.h

[PATCH] D33304: [clang-tidy] Add a new module Android and a new check for file descriptors.

2017-05-17 Thread Yan Wang via Phabricator via cfe-commits
yawanng created this revision.
yawanng added a project: clang-tools-extra.
Herald added subscribers: krytarowski, xazax.hun, mgorny, srhines.

A common source of security bugs has been code that opens file descriptors 
without using the O_CLOEXEC flag.  (Without that flag, an opened sensitive file 
would remain open across a fork+exec to a lower-privileged SELinux domain, 
leaking that sensitive data.).

open(), openat(), and open64() must include O_CLOEXEC in their flags argument.


https://reviews.llvm.org/D33304

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/FileDescriptorCheck.cpp
  clang-tidy/android/FileDescriptorCheck.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  unittests/clang-tidy/CMakeLists.txt

Index: unittests/clang-tidy/CMakeLists.txt
===
--- unittests/clang-tidy/CMakeLists.txt
+++ unittests/clang-tidy/CMakeLists.txt
@@ -26,6 +26,7 @@
   clangLex
   clangTidy
   clangTidyGoogleModule
+  clangTidyAndroidModule
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyReadabilityModule
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -477,6 +477,11 @@
 static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
 GoogleModuleAnchorSource;
 
+// This anchor is used to force the linker to link the AndroidModule.
+extern volatile int AndroidModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
+AndroidModuleAnchorSource;
+
 // This anchor is used to force the linker to link the MiscModule.
 extern volatile int MiscModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
Index: clang-tidy/tool/CMakeLists.txt
===
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -17,6 +17,7 @@
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
   clangTidyGoogleModule
+  clangTidyAndroidModule
   clangTidyHICPPModule
   clangTidyLLVMModule
   clangTidyMiscModule
Index: clang-tidy/plugin/CMakeLists.txt
===
--- clang-tidy/plugin/CMakeLists.txt
+++ clang-tidy/plugin/CMakeLists.txt
@@ -12,6 +12,7 @@
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
   clangTidyGoogleModule
+  clangTidyAndroidModule
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyModernizeModule
Index: clang-tidy/android/FileDescriptorCheck.h
===
--- clang-tidy/android/FileDescriptorCheck.h
+++ clang-tidy/android/FileDescriptorCheck.h
@@ -0,0 +1,46 @@
+//===--- FileDescriptorCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_FILE_DESCRIPTOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_FILE_DESCRIPTOR_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// Finds code that opens file descriptors without using the O_CLOEXEC flag.
+///
+/// open(), openat(), and open64() must include O_CLOEXEC in their flags
+/// argument.
+/// Only consider simple cases that the corresponding argument is constant or binary
+/// operation OR among constants like 'O_CLOEXEC' or 'O_CLOEXEC | O_RDONLY'. No constant
+/// propagation is performed.
+///
+/// https://b.corp.google.com/issues/36664104
+
+class FileDescriptorCheck : public ClangTidyCheck {
+public:
+  FileDescriptorCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+  bool checkFlags(const Expr *Flags);
+  bool checkFlag(const IntegerLiteral *Flag);
+private:
+  static constexpr const char *FLAG = "O_CLOEXEC";
+  static constexpr const char *HEADER_FILE = "fcntl.h";
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_FILE_DESCRIPTOR_H
Index: clang-tidy/android/FileDescriptorCheck.cpp
===
--- clang-tidy/android/FileDescriptorCheck.cpp
+++ clang-tidy/android/FileDescriptorCheck.cpp
@@ -0,0 +1,101 @@
+//===--- FileDescriptorCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the 

r303317 - The constant expression evaluator should examine function arguments for non-constexpr function calls unless the EvalInfo says to stop.

2017-05-17 Thread Nick Lewycky via cfe-commits
Author: nicholas
Date: Wed May 17 18:56:54 2017
New Revision: 303317

URL: http://llvm.org/viewvc/llvm-project?rev=303317=rev
Log:
The constant expression evaluator should examine function arguments for 
non-constexpr function calls unless the EvalInfo says to stop.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/integer-overflow.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=303317=303316=303317=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed May 17 18:56:54 2017
@@ -4579,7 +4579,7 @@ public:
   }
 
   bool handleCallExpr(const CallExpr *E, APValue ,
- const LValue *ResultSlot) {
+  const LValue *ResultSlot) {
 const Expr *Callee = E->getCallee()->IgnoreParens();
 QualType CalleeType = Callee->getType();
 
@@ -4588,6 +4588,23 @@ public:
 auto Args = llvm::makeArrayRef(E->getArgs(), E->getNumArgs());
 bool HasQualifier = false;
 
+struct EvaluateIgnoredRAII {
+public:
+  EvaluateIgnoredRAII(EvalInfo , llvm::ArrayRef ToEval)
+  : Info(Info), ToEval(ToEval) {}
+  ~EvaluateIgnoredRAII() {
+if (Info.noteFailure()) {
+  for (auto E : ToEval)
+EvaluateIgnoredValue(Info, E);
+}
+  }
+  void cancel() { ToEval = {}; }
+  void drop_front() { ToEval = ToEval.drop_front(); }
+private:
+  EvalInfo 
+  llvm::ArrayRef ToEval;
+} EvalArguments(Info, Args);
+
 // Extract function decl and 'this' pointer from the callee.
 if (CalleeType->isSpecificBuiltinType(BuiltinType::BoundMember)) {
   const ValueDecl *Member = nullptr;
@@ -4637,10 +4654,12 @@ public:
 if (Args.empty())
   return Error(E);
 
-if (!EvaluateObjectArgument(Info, Args[0], ThisVal))
+const Expr *FirstArg = Args[0];
+Args = Args.drop_front();
+EvalArguments.drop_front();
+if (!EvaluateObjectArgument(Info, FirstArg, ThisVal))
   return false;
 This = 
-Args = Args.slice(1);
   } else if (MD && MD->isLambdaStaticInvoker()) {   
 // Map the static invoker for the lambda back to the call operator.
 // Conveniently, we don't have to slice out the 'this' argument (as is
@@ -4692,8 +4711,12 @@ public:
 const FunctionDecl *Definition = nullptr;
 Stmt *Body = FD->getBody(Definition);
 
-if (!CheckConstexprFunction(Info, E->getExprLoc(), FD, Definition, Body) ||
-!HandleFunctionCall(E->getExprLoc(), Definition, This, Args, Body, 
Info,
+if (!CheckConstexprFunction(Info, E->getExprLoc(), FD, Definition, Body))
+  return false;
+
+EvalArguments.cancel();
+
+if (!HandleFunctionCall(E->getExprLoc(), Definition, This, Args, Body, 
Info,
 Result, ResultSlot))
   return false;
 

Modified: cfe/trunk/test/Sema/integer-overflow.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/integer-overflow.c?rev=303317=303316=303317=diff
==
--- cfe/trunk/test/Sema/integer-overflow.c (original)
+++ cfe/trunk/test/Sema/integer-overflow.c Wed May 17 18:56:54 2017
@@ -151,6 +151,14 @@ uint64_t check_integer_overflows(int i)
   uint64_t *b;
   uint64_t b2 = b[4608 * 1024 * 1024] + 1;
 
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 
'int'}} 
+  f0(4608 * 1024 * 1024);
+  f0(4608ul * 1024 * 1024);
+// expected-warning@+1 2{{overflow in expression; result is 536870912 with 
type 'int'}} 
+  f1(4608 * 1024 * 1024, 4608 * 1024 * 1024);
+// expected-warning@+1 2{{overflow in expression; result is 536870912 with 
type 'int'}} 
+  f2(4608 * 1024 * 1024, 4608 * 1024 * 1024);
+
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with 
type 'int'}}
   int j1 = i ? (4608 * 1024 * 1024) : (4608 * 1024 * 1024);
 


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


Re: r302966 - Remove unused tracking of owning module for MacroInfo objects.

2017-05-17 Thread Richard Smith via cfe-commits
I grabbed a clang binary from the build bot and have been trying to figure
out what's gone wrong. So far it looks like the msan-enabled stage1
miscompiled some part of clang's lib/Lex/TokenLexer.cpp (but I'm not sure
of that). It *looks* like TokenLexer::ExpandFunctionArguments is corrupting
the Flags member of the token, somewhere around the "if
(!VaArgsPseudoPaste)" block. I see what looks like a Token::Flags value of
0x2150, which is garbage: the highest assigned flag is 0x400.

On 17 May 2017 at 14:50, Vitaly Buka  wrote:

> Actually it was not "-w" but -DCMAKE_BUILD_TYPE=Release
> Also now I am not sure that it was r302966.
> Looking.
>
> On Wed, May 17, 2017 at 2:15 PM Vitaly Buka  wrote:
>
>> And looks like "-w" is needed to trigger this.
>>
>> On Wed, May 17, 2017 at 1:43 PM Vitaly Buka 
>> wrote:
>>
>>> On Tue, May 16, 2017 at 12:19 PM Richard Smith 
>>> wrote:
>>>
 On 16 May 2017 at 11:54, Vitaly Buka  wrote:

> The patch breaks this test http://lab.llvm.org:8011/
> builders/sanitizer-x86_64-linux-bootstrap/builds/1349/
> steps/check-clang%20msan/logs/stdio
>

 Given the nature of this change, that's a surprise, but anything's
 possible. How sure are you that it was this change?


>>> I bisected to the change locally.
>>>
>>>
 Script:
> --
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm_build_msan/./bin/clang -cc1 -internal-isystem
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm_build_msan/lib/clang/5.0.0/include
> -nostdsysteminc -verify -fms-extensions -Wmicrosoft
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_
> paste_msextensions.c
> not /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm_build_msan/./bin/clang -cc1 -internal-isystem
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm_build_msan/lib/clang/5.0.0/include
> -nostdsysteminc -P -E -fms-extensions /mnt/b/sanitizer-buildbot2/
> sanitizer-x86_64-linux-bootstrap/build/llvm/tools/
> clang/test/Preprocessor/macro_paste_msextensions.c |
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm_build_msan/./bin/FileCheck -strict-whitespace
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_
> paste_msextensions.c
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:35:1:
> error: pasting formed '(baz', an invalid preprocessing token
> bar(q) // expected-warning {{type specifier missing}} expected-error
> {{invalid preprocessing token}} expected-error {{parameter list without
> types}}
> ^
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:34:20:
> note: expanded from macro 'bar'
> #define bar(y) foo(##baz(y))
>^
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
> error: pasting formed '1a-', an invalid preprocessing token
> collapse_spaces(1a, b2, 3c, d4) // expected-error 4 {{invalid
> preprocessing token}} expected-error {{expected function body}}
> ^
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:43:
> note: expanded from macro 'collapse_spaces'
> #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
>   ^
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
> error: pasting formed '-b2', an invalid preprocessing token
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:48:
> note: expanded from macro 'collapse_spaces'
> #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
>^
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
> error: pasting formed 'b2-', an invalid preprocessing token
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-
> bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:53:
> note: expanded from macro 'collapse_spaces'
> #define collapse_spaces(a, b, c, d) 

[PATCH] D33284: [CodeGen] Propagate LValueBaseInfo instead of AlignmentSource

2017-05-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D33284#757917, @kparzysz wrote:

> Changed the getNatural.*TypeAlignment to produce the entire LValueBaseInfo, 
> assuming MayAlias to be false.
>
> Added merging of LValueBaseInfos.  The merging assumes that the alignment 
> source in the parameter overrides the existing source.  That works for the 
> existing cases (cast), but I'm not sure if that's correct in general.  Is 
> there is an implicit ordering of alignment sources?


There is an ordering of alignment sources, but we deliberately want casts to 
override alignment assumptions associated with the original value.  But that's 
why the merge operation is named mergeForCasts: it doesn't suggest it should be 
used for other operations.

Thank you, this looks great.


Repository:
  rL LLVM

https://reviews.llvm.org/D33284



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


[PATCH] D33284: [CodeGen] Propagate LValueBaseInfo instead of AlignmentSource

2017-05-17 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz updated this revision to Diff 99353.
kparzysz marked 2 inline comments as done.
kparzysz added a comment.

Changed the getNatural.*TypeAlignment to produce the entire LValueBaseInfo, 
assuming MayAlias to be false.

Added merging of LValueBaseInfos.  The merging assumes that the alignment 
source in the parameter overrides the existing source.  That works for the 
existing cases (cast), but I'm not sure if that's correct in general.  Is there 
is an implicit ordering of alignment sources?


Repository:
  rL LLVM

https://reviews.llvm.org/D33284

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGObjCRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1886,31 +1886,33 @@
   //======//
 
   LValue MakeAddrLValue(Address Addr, QualType T,
-AlignmentSource AlignSource = AlignmentSource::Type) {
-return LValue::MakeAddr(Addr, T, getContext(), AlignSource,
+LValueBaseInfo BaseInfo =
+LValueBaseInfo(AlignmentSource::Type)) {
+return LValue::MakeAddr(Addr, T, getContext(), BaseInfo,
 CGM.getTBAAInfo(T));
   }
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
-AlignmentSource AlignSource = AlignmentSource::Type) {
+LValueBaseInfo BaseInfo =
+LValueBaseInfo(AlignmentSource::Type)) {
 return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
-AlignSource, CGM.getTBAAInfo(T));
+BaseInfo, CGM.getTBAAInfo(T));
   }
 
   LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T);
   LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T);
   CharUnits getNaturalTypeAlignment(QualType T,
-AlignmentSource *Source = nullptr,
+LValueBaseInfo *BaseInfo = nullptr,
 bool forPointeeType = false);
   CharUnits getNaturalPointeeTypeAlignment(QualType T,
-   AlignmentSource *Source = nullptr);
+   LValueBaseInfo *BaseInfo = nullptr);
 
   Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy,
-  AlignmentSource *Source = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr);
   LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy);
 
   Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
-AlignmentSource *Source = nullptr);
+LValueBaseInfo *BaseInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
   /// CreateTempAlloca - This creates a alloca and inserts it into the entry
@@ -2992,8 +2994,8 @@
   /// the LLVM value representation.
   llvm::Value *EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty,
 SourceLocation Loc,
-AlignmentSource AlignSource =
-  AlignmentSource::Type,
+LValueBaseInfo BaseInfo =
+LValueBaseInfo(AlignmentSource::Type),
 llvm::MDNode *TBAAInfo = nullptr,
 QualType TBAABaseTy = QualType(),
 uint64_t TBAAOffset = 0,
@@ -3010,7 +3012,8 @@
   /// the LLVM value representation.
   void EmitStoreOfScalar(llvm::Value *Value, Address Addr,
  bool Volatile, QualType Ty,
- AlignmentSource AlignSource = AlignmentSource::Type,
+ LValueBaseInfo BaseInfo =
+ LValueBaseInfo(AlignmentSource::Type),
  llvm::MDNode *TBAAInfo = nullptr, bool isInit = false,
  QualType TBAABaseTy = QualType(),
  uint64_t TBAAOffset = 0, bool isNontemporal = false);
@@ -3083,7 +3086,7 @@
   RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc);
 
   Address EmitArrayToPointerDecay(const Expr *Array,
-  AlignmentSource *AlignSource = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr);
 
   class ConstantEmission {
 

Re: r302966 - Remove unused tracking of owning module for MacroInfo objects.

2017-05-17 Thread Vitaly Buka via cfe-commits
Actually it was not "-w" but -DCMAKE_BUILD_TYPE=Release
Also now I am not sure that it was r302966.
Looking.

On Wed, May 17, 2017 at 2:15 PM Vitaly Buka  wrote:

> And looks like "-w" is needed to trigger this.
>
> On Wed, May 17, 2017 at 1:43 PM Vitaly Buka  wrote:
>
>> On Tue, May 16, 2017 at 12:19 PM Richard Smith 
>> wrote:
>>
>>> On 16 May 2017 at 11:54, Vitaly Buka  wrote:
>>>
 The patch breaks this test
 http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/1349/steps/check-clang%20msan/logs/stdio

>>>
>>> Given the nature of this change, that's a surprise, but anything's
>>> possible. How sure are you that it was this change?
>>>
>>>
>> I bisected to the change locally.
>>
>>
>>> Script:
 --
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/./bin/clang
 -cc1 -internal-isystem
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/lib/clang/5.0.0/include
 -nostdsysteminc -verify -fms-extensions -Wmicrosoft
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c
 not
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/./bin/clang
 -cc1 -internal-isystem
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/lib/clang/5.0.0/include
 -nostdsysteminc -P -E -fms-extensions
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c
 |
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/./bin/FileCheck
 -strict-whitespace
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c
 --
 Exit Code: 1

 Command Output (stderr):
 --
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:35:1:
 error: pasting formed '(baz', an invalid preprocessing token
 bar(q) // expected-warning {{type specifier missing}} expected-error
 {{invalid preprocessing token}} expected-error {{parameter list without
 types}}
 ^
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:34:20:
 note: expanded from macro 'bar'
 #define bar(y) foo(##baz(y))
^
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
 error: pasting formed '1a-', an invalid preprocessing token
 collapse_spaces(1a, b2, 3c, d4) // expected-error 4 {{invalid
 preprocessing token}} expected-error {{expected function body}}
 ^
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:43:
 note: expanded from macro 'collapse_spaces'
 #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
   ^
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
 error: pasting formed '-b2', an invalid preprocessing token
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:48:
 note: expanded from macro 'collapse_spaces'
 #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
^
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
 error: pasting formed 'b2-', an invalid preprocessing token
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:53:
 note: expanded from macro 'collapse_spaces'
 #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
 ^
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
 error: pasting formed '-3c', an invalid preprocessing token
 /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:58:
 note: expanded from macro 'collapse_spaces'
 #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
  ^
 5 errors generated.
 

[PATCH] D33275: Keep into account if files were virtual.

2017-05-17 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

We have this pattern:

  FileID FID;
  const clang::FileEntry* FE
= SM.getFileManager().getVirtualFile(source_name.str(), InputSize,
 0 /* mod time*/);
  SM.overrideFileContents(FE, std::move(MB)); // MB is a llvm::MemoryBuffer
  FID = SM.createFileID(FE, NewLoc, SrcMgr::C_User);
  
  ...
  
  PP.EnterSourceFile(FID, /*DirLookup*/0, NewLoc); // PP is a 
clang::Preprocessor

If the memory buffer contains eg. '//expected-error: ...' this forces the 
ContentCache to compute some source location information IIRC. This leads in 
hitting the disk, ignoring the fact that this is a virtual file with an 
overridden content.

I will try to come up with a test but I may need to land some interpreter 
infrastructure first...


https://reviews.llvm.org/D33275



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


[PATCH] D33259: Don't defer to the GCC driver for linking arm-baremetal

2017-05-17 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked 2 inline comments as done.
jroelofs added inline comments.



Comment at: lib/Driver/ToolChains/BareMetal.cpp:107-108
+ArgStringList ) const {
+  CmdArgs.push_back("-lc++");
+  CmdArgs.push_back("-lc++abi");
+  CmdArgs.push_back("-lunwind");

jroelofs wrote:
> compnerd wrote:
> > I think that this is a bit extreme.  We already have `-stdlib=libc++` and 
> > `-stdlib=libstdc++`.  Why not just honor that?
> I wasn't going for "support every possible thing out of the tin", instead 
> preferring incremental development :)
Added support for `-stdlib=`.

I made the assumption that `-stdlib=libstdc++` implies the user wants libsupc++ 
as their ABI library, though someone may want libstdc++ + libc++abi, or other 
combinations. If that's the case, we can add `-abilib=`, and likewise 
`-unwinder=`... but let's save that for another patch, on another day.


https://reviews.llvm.org/D33259



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


[PATCH] D33259: Don't defer to the GCC driver for linking arm-baremetal

2017-05-17 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 99350.

https://reviews.llvm.org/D33259

Files:
  cmake/caches/BaremetalARM.cmake
  lib/Driver/CMakeLists.txt
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/BareMetal.cpp
  lib/Driver/ToolChains/BareMetal.h
  test/Driver/Inputs/baremetal_arm/include/c++/v1/.keep
  test/Driver/baremetal.cpp

Index: test/Driver/baremetal.cpp
===
--- /dev/null
+++ test/Driver/baremetal.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: -T semihosted.lds \
+// RUN: -L some/directory/user/asked/for \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
+// CHECK-V6M-C: "[[PREFIX_DIR:.*]]/bin/clang" "-cc1" "-triple" "thumbv6m-none--eabi"
+// CHECK-V6M-C-SAME: "-resource-dir" "[[PREFIX_DIR]]/lib/clang/[[VERSION:[^"]*]]"
+// CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]/include/c++/v1"
+// CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]/include"
+// CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-V6M-C-NEXT: "[[PREFIX_DIR:.*]]/bin/ld.lld" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-C-SAME: "-L[[PREFIX_DIR]]/lib/clang/[[VERSION]]/lib/baremetal"
+// CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome/directory/user/asked/for"
+// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
+// CHECK-V6M-DEFAULTCXX: "[[PREFIX_DIR:.*]]/bin/ld.lld" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-DEFAULTCXX-SAME: "-L[[PREFIX_DIR]]/lib/clang/{{.*}}/lib/baremetal"
+// CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: -stdlib=libc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBCXX %s
+// CHECK-V6M-LIBCXX: "[[PREFIX_DIR:.*]]/bin/ld.lld" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-LIBCXX-SAME: "-L[[PREFIX_DIR]]/lib/clang/{{.*}}/lib/baremetal"
+// CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: -stdlib=libstdc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBSTDCXX %s
+// CHECK-V6M-LIBSTDCXX: "[[PREFIX_DIR:.*]]/bin/ld.lld" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-LIBSTDCXX-SAME: "-L[[PREFIX_DIR]]/lib/clang/{{.*}}/lib/baremetal"
+// CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
+// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: -nodefaultlibs \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-NDL %s
+// CHECK-V6M-NDL: "[[PREFIX_DIR:.*]]/bin/ld.lld" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-NDL-SAME: "-L[[PREFIX_DIR]]/lib/clang/{{.*}}/lib/baremetal" "-o" "{{.*}}.o"
Index: lib/Driver/ToolChains/BareMetal.h
===
--- /dev/null
+++ lib/Driver/ToolChains/BareMetal.h
@@ -0,0 +1,84 @@
+//===--- BareMetal.h - Bare Metal Tool and ToolChain -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H
+
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+#include 
+
+namespace clang {
+namespace driver {
+
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
+public:
+  BareMetal(const Driver , const llvm::Triple ,
+const llvm::opt::ArgList );
+  ~BareMetal() override;
+
+  static bool handlesTarget(const llvm::Triple );
+protected:
+  Tool *buildLinker() const override;
+
+public:
+  bool useIntegratedAs() const override { return true; }
+  bool isCrossCompiling() const override { return true; }
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return false; }
+  bool SupportsProfiling() const override { return true; }
+  bool SupportsObjCGC() const override { return false; }
+
+  const char *getDefaultLinker() const override { 

[PATCH] D33259: Don't defer to the GCC driver for linking arm-baremetal

2017-05-17 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: lib/Driver/ToolChains/BareMetal.h:42
+
+  const char *getDefaultLinker() const override { return "ld.lld"; }
+

compnerd wrote:
> I think that this really should be `ld` still, as that is the canonical name 
> for the linker.
You mean `lld`?

```
$ lld
lld is a generic driver.
Invoke ld.lld (Unix), ld (macOS) or lld-link (Windows) instead.
```

Or are you saying: "make binutils ld the default, not llvm's lld"?


https://reviews.llvm.org/D33259



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


[PATCH] D32248: CodeGen: Cast alloca to expected address space

2017-05-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Any further comments? Thanks.


https://reviews.llvm.org/D32248



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


Re: r302966 - Remove unused tracking of owning module for MacroInfo objects.

2017-05-17 Thread Vitaly Buka via cfe-commits
And looks like "-w" is needed to trigger this.

On Wed, May 17, 2017 at 1:43 PM Vitaly Buka  wrote:

> On Tue, May 16, 2017 at 12:19 PM Richard Smith 
> wrote:
>
>> On 16 May 2017 at 11:54, Vitaly Buka  wrote:
>>
>>> The patch breaks this test
>>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/1349/steps/check-clang%20msan/logs/stdio
>>>
>>
>> Given the nature of this change, that's a surprise, but anything's
>> possible. How sure are you that it was this change?
>>
>>
> I bisected to the change locally.
>
>
>> Script:
>>> --
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/./bin/clang
>>> -cc1 -internal-isystem
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/lib/clang/5.0.0/include
>>> -nostdsysteminc -verify -fms-extensions -Wmicrosoft
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c
>>> not
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/./bin/clang
>>> -cc1 -internal-isystem
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/lib/clang/5.0.0/include
>>> -nostdsysteminc -P -E -fms-extensions
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c
>>> |
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/./bin/FileCheck
>>> -strict-whitespace
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c
>>> --
>>> Exit Code: 1
>>>
>>> Command Output (stderr):
>>> --
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:35:1:
>>> error: pasting formed '(baz', an invalid preprocessing token
>>> bar(q) // expected-warning {{type specifier missing}} expected-error
>>> {{invalid preprocessing token}} expected-error {{parameter list without
>>> types}}
>>> ^
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:34:20:
>>> note: expanded from macro 'bar'
>>> #define bar(y) foo(##baz(y))
>>>^
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
>>> error: pasting formed '1a-', an invalid preprocessing token
>>> collapse_spaces(1a, b2, 3c, d4) // expected-error 4 {{invalid
>>> preprocessing token}} expected-error {{expected function body}}
>>> ^
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:43:
>>> note: expanded from macro 'collapse_spaces'
>>> #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
>>>   ^
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
>>> error: pasting formed '-b2', an invalid preprocessing token
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:48:
>>> note: expanded from macro 'collapse_spaces'
>>> #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
>>>^
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
>>> error: pasting formed 'b2-', an invalid preprocessing token
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:53:
>>> note: expanded from macro 'collapse_spaces'
>>> #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
>>> ^
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
>>> error: pasting formed '-3c', an invalid preprocessing token
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:58:
>>> note: expanded from macro 'collapse_spaces'
>>> #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
>>>  ^
>>> 5 errors generated.
>>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:44:11:
>>> error: expected string not found in input
>>> // CHECK: "1a-b2-3cd4"
>>>   ^
>>> :34:1: note: scanning from here
>>> "1a-b2- 3cd4"
>>> ^
>>>
>>>
>>> On Mon, May 15, 2017 at 10:28 AM Jordan Rose via cfe-commits <
>>> 

[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-05-17 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

In https://reviews.llvm.org/D28952#757375, @iris wrote:

> Thank you for helping me build clang with z3.I have already applied the above 
> updating.But now I have another question, when running clang with '-Xanalyzer 
> -analyzer-constraints=z3' there is always be a fatal error and I don't know 
> whether it is right to use a command like 'clang -Xanalyzer 
> -analyzer-constraints=z3 -analyzer-checker=debug.DumpExplodedGraph test.cpp-' 
> to get the ExplodedGraph which is analyzed by z3constraint?Sorry to bother.


You probably want something along the lines of `clang --analyze -Xanalyzer 
-analyzer-constraints=z3 -Xanalyzer -analyzer-checker=debug.ViewExplodedGraph 
test.c`. In particular, there is a difference between using clang as a compiler 
driver or frontend (see FAQ entry on cc1 at 
https://clang.llvm.org/docs/FAQ.html). This is also mentioned in the checker 
development manual: https://clang-analyzer.llvm.org/checker_dev_manual.html .


Repository:
  rL LLVM

https://reviews.llvm.org/D28952



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


Re: r302966 - Remove unused tracking of owning module for MacroInfo objects.

2017-05-17 Thread Vitaly Buka via cfe-commits
On Tue, May 16, 2017 at 12:19 PM Richard Smith 
wrote:

> On 16 May 2017 at 11:54, Vitaly Buka  wrote:
>
>> The patch breaks this test
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/1349/steps/check-clang%20msan/logs/stdio
>>
>
> Given the nature of this change, that's a surprise, but anything's
> possible. How sure are you that it was this change?
>
>
I bisected to the change locally.


> Script:
>> --
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/./bin/clang
>> -cc1 -internal-isystem
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/lib/clang/5.0.0/include
>> -nostdsysteminc -verify -fms-extensions -Wmicrosoft
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c
>> not
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/./bin/clang
>> -cc1 -internal-isystem
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/lib/clang/5.0.0/include
>> -nostdsysteminc -P -E -fms-extensions
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c
>> |
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm_build_msan/./bin/FileCheck
>> -strict-whitespace
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c
>> --
>> Exit Code: 1
>>
>> Command Output (stderr):
>> --
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:35:1:
>> error: pasting formed '(baz', an invalid preprocessing token
>> bar(q) // expected-warning {{type specifier missing}} expected-error
>> {{invalid preprocessing token}} expected-error {{parameter list without
>> types}}
>> ^
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:34:20:
>> note: expanded from macro 'bar'
>> #define bar(y) foo(##baz(y))
>>^
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
>> error: pasting formed '1a-', an invalid preprocessing token
>> collapse_spaces(1a, b2, 3c, d4) // expected-error 4 {{invalid
>> preprocessing token}} expected-error {{expected function body}}
>> ^
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:43:
>> note: expanded from macro 'collapse_spaces'
>> #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
>>   ^
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
>> error: pasting formed '-b2', an invalid preprocessing token
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:48:
>> note: expanded from macro 'collapse_spaces'
>> #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
>>^
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
>> error: pasting formed 'b2-', an invalid preprocessing token
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:53:
>> note: expanded from macro 'collapse_spaces'
>> #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
>> ^
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:42:1:
>> error: pasting formed '-3c', an invalid preprocessing token
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:41:58:
>> note: expanded from macro 'collapse_spaces'
>> #define collapse_spaces(a, b, c, d) str(a ## - ## b ## - ## c ## d)
>>  ^
>> 5 errors generated.
>> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Preprocessor/macro_paste_msextensions.c:44:11:
>> error: expected string not found in input
>> // CHECK: "1a-b2-3cd4"
>>   ^
>> :34:1: note: scanning from here
>> "1a-b2- 3cd4"
>> ^
>>
>>
>> On Mon, May 15, 2017 at 10:28 AM Jordan Rose via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Hi, Richard. Swift was using this information in order to put imported
>>> macros in a particular context. It wouldn't surprise me to hear that we
>>> were doing it wrong, and 

[PATCH] D33284: [CodeGen] Propagate LValueBaseInfo instead of AlignmentSource

2017-05-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:2256
 Address(CapLVal.getPointer(), getContext().getDeclAlign(VD)),
-CapLVal.getType(), AlignmentSource::Decl);
+CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl, 
MayAlias));
   }

kparzysz wrote:
> rjmccall wrote:
> > Hmm.  I think your side of this is right, but I'm not sure that the 
> > original code is correct to override with AlignmentSource::Decl, because 
> > the captured field might be a reference.  In fact, I'm not sure why this is 
> > overwriting the alignment, either; it should be able to just return the 
> > result of EmitCapturedFieldLValue, and that should be more correct for the 
> > same reason.  Do any tests break if you do that?
> There is one failure in check-clang: test/OpenMP/task_codegen.cpp.
> 
> 
> ```
> ; Function Attrs: noinline nounwind
> define internal i32 @.omp_task_entry..14(i32, 
> %struct.kmp_task_t_with_privates.13* noalias) #1 {
> entry:
>   %.global_tid..addr.i = alloca i32, align 4
>   %.part_id..addr.i = alloca i32*, align 8
>   %.privates..addr.i = alloca i8*, align 8
>   %.copy_fn..addr.i = alloca void (i8*, ...)*, align 8
>   %.task_t..addr.i = alloca i8*, align 8
>   %__context.addr.i = alloca %struct.anon.12*, align 8
>   %.addr = alloca i32, align 4
>   %.addr1 = alloca %struct.kmp_task_t_with_privates.13*, align 8
>   store i32 %0, i32* %.addr, align 4
>   store %struct.kmp_task_t_with_privates.13* %1, 
> %struct.kmp_task_t_with_privates.13** %.addr1, align 8
>   %2 = load i32, i32* %.addr, align 4
>   %3 = load %struct.kmp_task_t_with_privates.13*, 
> %struct.kmp_task_t_with_privates.13** %.addr1, align 8
>   %4 = getelementptr inbounds %struct.kmp_task_t_with_privates.13, 
> %struct.kmp_task_t_with_privates.13* %3, i32 0, i32 0
>   %5 = getelementptr inbounds %struct.kmp_task_t, %struct.kmp_task_t* %4, i32 
> 0, i32 2
>   %6 = getelementptr inbounds %struct.kmp_task_t, %struct.kmp_task_t* %4, i32 
> 0, i32 0
>   %7 = load i8*, i8** %6, align 8
>   %8 = bitcast i8* %7 to %struct.anon.12*
>   %9 = bitcast %struct.kmp_task_t_with_privates.13* %3 to i8*
>   store i32 %2, i32* %.global_tid..addr.i, align 4
>   store i32* %5, i32** %.part_id..addr.i, align 8
>   store i8* null, i8** %.privates..addr.i, align 8
>   store void (i8*, ...)* null, void (i8*, ...)** %.copy_fn..addr.i, align 8
>   store i8* %9, i8** %.task_t..addr.i, align 8
>   store %struct.anon.12* %8, %struct.anon.12** %__context.addr.i, align 8
>   %10 = load %struct.anon.12*, %struct.anon.12** %__context.addr.i, align 8
>   store i32 4, i32* @a, align 4
>   %11 = getelementptr inbounds %struct.anon.12, %struct.anon.12* %10, i32 0, 
> i32 0
>   %ref.i = load i32*, i32** %11, align 8
>   store i32 5, i32* %ref.i, align 128  // XXX This alignment is 4 with 
> that change.
>   ret i32 0
> }
> ```
> 
Ah, okay, I see what's happening here.  The field is actually *always* a 
reference, and and because it's just a reference the type doesn't have the 
declared alignment of the variable.

I think your change is probably the most reasonable approach.


Repository:
  rL LLVM

https://reviews.llvm.org/D33284



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


[PATCH] D33284: [CodeGen] Propagate LValueBaseInfo instead of AlignmentSource

2017-05-17 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:2256
 Address(CapLVal.getPointer(), getContext().getDeclAlign(VD)),
-CapLVal.getType(), AlignmentSource::Decl);
+CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl, 
MayAlias));
   }

rjmccall wrote:
> Hmm.  I think your side of this is right, but I'm not sure that the original 
> code is correct to override with AlignmentSource::Decl, because the captured 
> field might be a reference.  In fact, I'm not sure why this is overwriting 
> the alignment, either; it should be able to just return the result of 
> EmitCapturedFieldLValue, and that should be more correct for the same reason. 
>  Do any tests break if you do that?
There is one failure in check-clang: test/OpenMP/task_codegen.cpp.


```
; Function Attrs: noinline nounwind
define internal i32 @.omp_task_entry..14(i32, 
%struct.kmp_task_t_with_privates.13* noalias) #1 {
entry:
  %.global_tid..addr.i = alloca i32, align 4
  %.part_id..addr.i = alloca i32*, align 8
  %.privates..addr.i = alloca i8*, align 8
  %.copy_fn..addr.i = alloca void (i8*, ...)*, align 8
  %.task_t..addr.i = alloca i8*, align 8
  %__context.addr.i = alloca %struct.anon.12*, align 8
  %.addr = alloca i32, align 4
  %.addr1 = alloca %struct.kmp_task_t_with_privates.13*, align 8
  store i32 %0, i32* %.addr, align 4
  store %struct.kmp_task_t_with_privates.13* %1, 
%struct.kmp_task_t_with_privates.13** %.addr1, align 8
  %2 = load i32, i32* %.addr, align 4
  %3 = load %struct.kmp_task_t_with_privates.13*, 
%struct.kmp_task_t_with_privates.13** %.addr1, align 8
  %4 = getelementptr inbounds %struct.kmp_task_t_with_privates.13, 
%struct.kmp_task_t_with_privates.13* %3, i32 0, i32 0
  %5 = getelementptr inbounds %struct.kmp_task_t, %struct.kmp_task_t* %4, i32 
0, i32 2
  %6 = getelementptr inbounds %struct.kmp_task_t, %struct.kmp_task_t* %4, i32 
0, i32 0
  %7 = load i8*, i8** %6, align 8
  %8 = bitcast i8* %7 to %struct.anon.12*
  %9 = bitcast %struct.kmp_task_t_with_privates.13* %3 to i8*
  store i32 %2, i32* %.global_tid..addr.i, align 4
  store i32* %5, i32** %.part_id..addr.i, align 8
  store i8* null, i8** %.privates..addr.i, align 8
  store void (i8*, ...)* null, void (i8*, ...)** %.copy_fn..addr.i, align 8
  store i8* %9, i8** %.task_t..addr.i, align 8
  store %struct.anon.12* %8, %struct.anon.12** %__context.addr.i, align 8
  %10 = load %struct.anon.12*, %struct.anon.12** %__context.addr.i, align 8
  store i32 4, i32* @a, align 4
  %11 = getelementptr inbounds %struct.anon.12, %struct.anon.12* %10, i32 0, 
i32 0
  %ref.i = load i32*, i32** %11, align 8
  store i32 5, i32* %ref.i, align 128  // XXX This alignment is 4 with that 
change.
  ret i32 0
}
```



Repository:
  rL LLVM

https://reviews.llvm.org/D33284



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


[PATCH] D33290: [libcxx] [test] Remove workaround for C1XX conversion-to-nullptr bug

2017-05-17 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter marked an inline comment as done.
CaseyCarter added inline comments.



Comment at: test/support/test_workarounds.h:21
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE

STL_MSFT wrote:
> Do you need to go update the tests that were using this?
Yes, thanks, `poisoned_hash_helper.hpp` didn't make it into the commit.


https://reviews.llvm.org/D33290



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


[PATCH] D33290: [libcxx] [test] Remove workaround for C1XX conversion-to-nullptr bug

2017-05-17 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 99336.
CaseyCarter added a comment.

Commit the change to the affected test code as well.


https://reviews.llvm.org/D33290

Files:
  test/support/poisoned_hash_helper.hpp
  test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
  test/support/test_workarounds.h


Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -14,15 +14,14 @@
 #include "test_macros.h"
 
 #if defined(TEST_COMPILER_EDG)
-# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR // VSO#424280
 #endif
 
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
-# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE // VSO#117743
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION // VSO#109062
 # ifndef _MSC_EXTENSIONS
-#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK // VSO#119998
 # endif
 #endif
 
Index: 
test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
===
--- 
test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
-
-#include 
-
-#include "test_workarounds.h"
-
-struct ConvertsToNullptr {
-  using DestType = decltype(nullptr);
-  operator DestType() const { return nullptr; }
-};
-
-int main() {
-#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
-  static_assert(!std::is_convertible::value, "");
-#else
-  static_assert(std::is_convertible::value, "");
-#endif
-}
Index: test/support/poisoned_hash_helper.hpp
===
--- test/support/poisoned_hash_helper.hpp
+++ test/support/poisoned_hash_helper.hpp
@@ -50,11 +50,9 @@
 // specializations of hash for nullptr t and all cv-unqualified
 // arithmetic, enumeration, and pointer types.
 using LibraryHashTypes = TypeList<
-#if !defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
 #if TEST_STD_VER > 14
   decltype(nullptr),
 #endif
-#endif
   bool,
   char,
   signed char,


Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -14,15 +14,14 @@
 #include "test_macros.h"
 
 #if defined(TEST_COMPILER_EDG)
-# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR // VSO#424280
 #endif
 
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
-# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE // VSO#117743
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION // VSO#109062
 # ifndef _MSC_EXTENSIONS
-#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK // VSO#119998
 # endif
 #endif
 
Index: test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
===
--- test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
-
-#include 
-
-#include "test_workarounds.h"
-
-struct ConvertsToNullptr {
-  using DestType = decltype(nullptr);
-  operator DestType() const { return nullptr; }
-};
-
-int main() {
-#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
-  static_assert(!std::is_convertible::value, "");
-#else
-  

[libcxx] r303281 - Make next/prev/advance/distance operations on iterators be constexpr. I missed this when I implemented the rest of P0031R0

2017-05-17 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed May 17 13:51:36 2017
New Revision: 303281

URL: http://llvm.org/viewvc/llvm-project?rev=303281=rev
Log:
Make next/prev/advance/distance operations on iterators be constexpr. I missed 
this when I implemented the rest of P0031R0

Modified:
libcxx/trunk/include/iterator

libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp

libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp

libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp

libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
libcxx/trunk/test/support/test_iterators.h

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=303281=303280=303281=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Wed May 17 13:51:36 2017
@@ -64,14 +64,23 @@ struct forward_iterator_tag   : publ
 struct bidirectional_iterator_tag : public forward_iterator_tag   {};
 struct random_access_iterator_tag : public bidirectional_iterator_tag {};
 
+// 27.4.3, iterator operations
 // extension: second argument not conforming to C++03
-template 
-void advance(InputIterator& i,
+template   // constexpr in C++17
+  constexpr void advance(InputIterator& i,
  typename iterator_traits::difference_type n);
 
-template 
-typename iterator_traits::difference_type
-distance(InputIterator first, InputIterator last);
+template   // constexpr in C++17
+  constexpr typename iterator_traits::difference_type
+distance(InputIterator first, InputIterator last);
+
+template   // constexpr in C++17
+  constexpr InputIterator next(InputIterator x,
+typename iterator_traits::difference_type n = 1);
+
+template   // constexpr in C++17
+  constexpr BidirectionalIterator prev(BidirectionalIterator x,
+typename iterator_traits::difference_type n = 1);   
 
 
 template 
 class reverse_iterator
@@ -529,7 +538,7 @@ struct _LIBCPP_TEMPLATE_VIS iterator
 };
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 void __advance(_InputIter& __i,
  typename iterator_traits<_InputIter>::difference_type __n, 
input_iterator_tag)
 {
@@ -538,7 +547,7 @@ void __advance(_InputIter& __i,
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 void __advance(_BiDirIter& __i,
  typename iterator_traits<_BiDirIter>::difference_type __n, 
bidirectional_iterator_tag)
 {
@@ -551,7 +560,7 @@ void __advance(_BiDirIter& __i,
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 void __advance(_RandIter& __i,
  typename iterator_traits<_RandIter>::difference_type __n, 
random_access_iterator_tag)
 {
@@ -559,7 +568,7 @@ void __advance(_RandIter& __i,
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 void advance(_InputIter& __i,
  typename iterator_traits<_InputIter>::difference_type __n)
 {
@@ -567,7 +576,7 @@ void advance(_InputIter& __i,
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 typename iterator_traits<_InputIter>::difference_type
 __distance(_InputIter __first, _InputIter __last, input_iterator_tag)
 {
@@ -578,7 +587,7 @@ __distance(_InputIter __first, _InputIte
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 typename iterator_traits<_RandIter>::difference_type
 __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
 {
@@ -586,7 +595,7 @@ __distance(_RandIter __first, _RandIter
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 typename iterator_traits<_InputIter>::difference_type
 distance(_InputIter __first, _InputIter __last)
 {
@@ -594,7 +603,7 @@ distance(_InputIter __first, _InputIter
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 _InputIter
 next(_InputIter __x,
  typename iterator_traits<_InputIter>::difference_type __n = 1,
@@ -605,7 +614,7 @@ next(_InputIter __x,
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 _BidiretionalIter
 prev(_BidiretionalIter __x,
  typename iterator_traits<_BidiretionalIter>::difference_type __n = 1,

Modified: 
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp?rev=303281=303280=303281=diff

[PATCH] D33290: [libcxx] [test] Remove workaround for C1XX conversion-to-nullptr bug

2017-05-17 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added inline comments.



Comment at: test/support/test_workarounds.h:21
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE

Do you need to go update the tests that were using this?


https://reviews.llvm.org/D33290



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


[PATCH] D33284: [CodeGen] Propagate LValueBaseInfo instead of AlignmentSource

2017-05-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Generally looks great, thanks!




Comment at: lib/CodeGen/CGBlocks.cpp:923
+ MakeAddrLValue(blockField, type,
+ LValueBaseInfo(AlignmentSource::Decl, false)),
  /*captured by init*/ false);

Please indent this line a little more to make it clear that it's part of the 
same argument.



Comment at: lib/CodeGen/CGExpr.cpp:884
+  if (BaseInfo)
+BaseInfo->setAlignmentSource(Source);
 }

Places that fall back to the type of a pointer/reference/whatever should 
probably compute the entire BaseInfo from the type.  For example, if we wanted 
to properly support attribute may_alias on types, we'd need to compute it here. 
 So I think you should probably change getNaturalTypeAlignment and 
getNaturalPointeeTypeAlignment to produce an entire BaseInfo, even if you 
always fill it in with may_alias=false for now.

Here you'll also need to merge the BaseInfos of the original pointer and the 
new one.  You should probably have a method on LValueBaseInfo that does that, 
called maybe mergeForCast?



Comment at: lib/CodeGen/CGExpr.cpp:2256
 Address(CapLVal.getPointer(), getContext().getDeclAlign(VD)),
-CapLVal.getType(), AlignmentSource::Decl);
+CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl, 
MayAlias));
   }

Hmm.  I think your side of this is right, but I'm not sure that the original 
code is correct to override with AlignmentSource::Decl, because the captured 
field might be a reference.  In fact, I'm not sure why this is overwriting the 
alignment, either; it should be able to just return the result of 
EmitCapturedFieldLValue, and that should be more correct for the same reason.  
Do any tests break if you do that?


Repository:
  rL LLVM

https://reviews.llvm.org/D33284



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


[PATCH] D32437: [analyzer] Nullability: fix a crash when adding notes inside a synthesized property accessor.

2017-05-17 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Thanks! A couple of minor comments below.




Comment at: lib/StaticAnalyzer/Core/PathDiagnostic.cpp:699
+  // We cannot place diagnostics on autosynthesized code.
+  // Put them onto the call site through which we jumped into autosynthesized
+  // code for the first time.

Nit: You could probably factor this into a nicely named helper function.



Comment at: lib/StaticAnalyzer/Core/PathDiagnostic.cpp:704
+const LocationContext *ParentLC = LC->getParent();
+while (ParentLC->getAnalysisDeclContext()->isBodyAutosynthesized()) {
+  LC = ParentLC;

Is ParentLC guaranteed never to be null? I would prefer checking for it inside 
the while. Even if it is not likely to happen now, the code could evolve to 
handle more cases..



Comment at: lib/StaticAnalyzer/Core/PathDiagnostic.cpp:932
+MD->isPropertyAccessor() &&
+CalleeCtx->getAnalysisDeclContext()->isBodyAutosynthesized());
 }

There was a case where we wanted to produce events for auto synthesized code, 
could you add a comment on what they were? (Otherwise, it's not clear why we 
need the isPropertyAccessor check.)


https://reviews.llvm.org/D32437



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


[PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-05-17 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Parse/ParseStmtAsm.cpp:100
+  // result of a call to LookupInlineAsmIdentifier.
+  bool EvaluateLookupAsEnum(void *LookupResult, int64_t ) {
+if (!LookupResult) return false;

Please format this, clang-format will do the job



Comment at: test/CodeGen/x86-ms-inline-asm-enum_feature.cpp:12
+  const int a = 0;
+  // CHECK-NOT: mov eax, [$$0]
+  __asm mov eax, [a]

Use CHECK-LABEL, CHECK, and CHECK-SAME the way that the existing 
ms-inline-asm.c tests do so that this test is easier to debug when it fails.


Repository:
  rL LLVM

https://reviews.llvm.org/D33277



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


[PATCH] D33278: [LLVM][x86][Inline Asm] - Enum support for MS syntax

2017-05-17 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Please consider using the monorepo to upload and submit this as a single patch.




Comment at: include/llvm/MC/MCParser/MCAsmParser.h:64
 unsigned ) = 0;
+  virtual bool EvaluateLookupAsEnum(void *LookupResult,int64_t ) = 0;
 };

It would be cleaner if InlineAsmIdentifierInfo simply contained an APInt 
indicating that the identifier in question was an enum, or other integral 
constant expression. Less callbacks to implement.



Comment at: lib/Target/X86/AsmParser/X86AsmParser.cpp:722
+  bool ParseIntelExpression(IntelExprStateMachine , SMLoc , 
+bool );
   std::unique_ptr

Please try to eliminate the need for this extra boolean out parameter.


Repository:
  rL LLVM

https://reviews.llvm.org/D33278



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


[PATCH] D33290: [libcxx] [test] Remove workaround for C1XX conversion-to-nullptr bug

2017-05-17 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

VSO#391542 "Types can't be convertible to nullptr_t," which will be fixed in 
the next release of Visual C++.

Also put internal bug numbers on the workarounds in test_workarounds.h for ease 
of correlation.


https://reviews.llvm.org/D33290

Files:
  test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
  test/support/test_workarounds.h


Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -14,15 +14,14 @@
 #include "test_macros.h"
 
 #if defined(TEST_COMPILER_EDG)
-# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR // VSO#424280
 #endif
 
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
-# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE // VSO#117743
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION // VSO#109062
 # ifndef _MSC_EXTENSIONS
-#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK // VSO#119998
 # endif
 #endif
 
Index: 
test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
===
--- 
test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
-
-#include 
-
-#include "test_workarounds.h"
-
-struct ConvertsToNullptr {
-  using DestType = decltype(nullptr);
-  operator DestType() const { return nullptr; }
-};
-
-int main() {
-#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
-  static_assert(!std::is_convertible::value, "");
-#else
-  static_assert(std::is_convertible::value, "");
-#endif
-}


Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -14,15 +14,14 @@
 #include "test_macros.h"
 
 #if defined(TEST_COMPILER_EDG)
-# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR // VSO#424280
 #endif
 
 #if defined(TEST_COMPILER_C1XX)
-# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
-# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
-# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE // VSO#117743
+# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION // VSO#109062
 # ifndef _MSC_EXTENSIONS
-#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+#  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK // VSO#119998
 # endif
 #endif
 
Index: test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
===
--- test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR.
-
-#include 
-
-#include "test_workarounds.h"
-
-struct ConvertsToNullptr {
-  using DestType = decltype(nullptr);
-  operator DestType() const { return nullptr; }
-};
-
-int main() {
-#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR)
-  static_assert(!std::is_convertible::value, "");
-#else
-  static_assert(std::is_convertible::value, "");
-#endif
-}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33275: Keep into account if files were virtual.

2017-05-17 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi Vassil,

In which case specifically this trigger for you? I'm curious because we're 
sometimes hitting non-deterministic crashes in ComputeLineNumbers, wonder if 
it's related.
Any chance you can come up with a testcase?


https://reviews.llvm.org/D33275



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


Re: Potential self-hosting failure

2017-05-17 Thread Renato Golin via cfe-commits
On 17 May 2017 at 18:07, John Brawn  wrote:
> I've now tracked this down to a problem with LEApcrel rematerialization
> where the rematerialized LEApcrel can address a different literal pool
> to the original. I've raised https://bugs.llvm.org/show_bug.cgi?id=33074

Sounds nasty!


> This is actually a bug that already existed before my patches, but because
> my patches made LEApcrel be rematerialized in more situations they made it
> more likely to trigger the bug. I'll continue looking into this to see if
> I can figure out how to fix it.

Thanks John!

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


RE: Potential self-hosting failure

2017-05-17 Thread John Brawn via cfe-commits
I've now tracked this down to a problem with LEApcrel rematerialization
where the rematerialized LEApcrel can address a different literal pool
to the original. I've raised https://bugs.llvm.org/show_bug.cgi?id=33074

This is actually a bug that already existed before my patches, but because
my patches made LEApcrel be rematerialized in more situations they made it
more likely to trigger the bug. I'll continue looking into this to see if
I can figure out how to fix it.

John

> -Original Message-
> From: Renato Golin [mailto:renato.go...@linaro.org]
> Sent: 16 May 2017 19:13
> To: John Brawn
> Cc: James Molloy; Diana Picus; LLVM Commits; Clang Commits; nd
> Subject: Re: Potential self-hosting failure
> 
> On 16 May 2017 at 18:26, John Brawn  wrote:
> > I've managed to reproduce this, but no luck so far in figuring out
> > what exactly is going wrong. I'll continue looking into it tomorrow.
> 
> Thanks John,
> 
> I have reverted it for now on r303193, to get the bots green.
> 
> cheers,
> --renato
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-05-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added inline comments.



Comment at: unittests/Format/FormatTest.cpp:2476
   "bool value = a\n"
-  " + a\n"
-  " + a\n"
-  " == a\n"
-  "* b\n"
-  "+ b\n"
-  " && a\n"
-  "* a\n"
-  "> c;",
+  "   + a\n"
+  "   + a\n"

Typz wrote:
> djasper wrote:
> > This looks very inconsistent to me.
> not sure what you mean, I do not really understand how this expression was 
> aligned before the patch...
> it is not so much better in this case with the patch, but the '&&' is 
> actually right-aligned with the '=' sign.
Seeing the test just before, I see (when breaking after operators) that the 
operands are actually right-aligned, e.g. all operators are on the same column.

So should it not be the same when breaking before the operator as well 
(independently from my patch, actually)?

  bool value = a\n"
 + a\n"
 + a\n"
== a\n"
 * b\n"
 + b\n"
&& a\n"
 * a\n"
 > c;

Not sure I like this right-alignment thing, but at least I start to understand 
how we get this output (and this may be another option to prefer 
left-alignment?)


https://reviews.llvm.org/D32478



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


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-05-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

we are using this style at our company, not sure if it is used elsewhere; I 
will check.

however, it seems to me that this behavior does not match the name of the 
option : AlignOperands does not align the operands anymore when 
BreakBeforeBinaryOperators is set...
so, for this patch to go forward, should I change AlignOperands into 
OperandAlignment enum, with 3 options? Something like

- OA_NotAligned, same as AlignOperands=false
- OA_AlignOperator, same the current AlignOperands=true
- OA_AlignOperands, same as AlignOperands=true when 
BreakBeforeBinaryOperators=false but my "new" mode when 
BreakBeforeBinaryOperators=true




Comment at: unittests/Format/FormatTest.cpp:2476
   "bool value = a\n"
-  " + a\n"
-  " + a\n"
-  " == a\n"
-  "* b\n"
-  "+ b\n"
-  " && a\n"
-  "* a\n"
-  "> c;",
+  "   + a\n"
+  "   + a\n"

djasper wrote:
> This looks very inconsistent to me.
not sure what you mean, I do not really understand how this expression was 
aligned before the patch...
it is not so much better in this case with the patch, but the '&&' is actually 
right-aligned with the '=' sign.


https://reviews.llvm.org/D32478



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


[PATCH] D33250: [Sema][ObjC] Fix a bug where -Wunguarded-availability was emitted at the wrong location

2017-05-17 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/SemaObjC/unguarded-availability.m:141
+@interface InterWithProp // expected-note 2 {{marked partial here}}
+@property int x;
+@end

Should this be `@property(class)`?


https://reviews.llvm.org/D33250



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


[PATCH] D33250: [Sema][ObjC] Fix a bug where -Wunguarded-availability was emitted at the wrong location

2017-05-17 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Hmm, I don't like how we end with a location that points to `x` instead of 
`InterWithProp`. Can we ignore the TypeLocs with invalid location and instead 
look at `ObjCPropertyRefExpr`s with a class receiver?


https://reviews.llvm.org/D33250



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


[PATCH] D32524: [clang-format] Fix MatchingOpeningBlockLineIndex computation

2017-05-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

I don't have commit access, can someone please commit this patch?


https://reviews.llvm.org/D32524



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


[PATCH] D33285: clang-format: do not reflow bullet lists

2017-05-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz created this revision.
Herald added a subscriber: klimek.

This patch prevents reflowing bullet lists in block comments.

It handles all lists supported by doxygen and markdown, e.g. bullet
lists starting with '-', '*', '+', as well as numbered lists starting
with -# or a number followed by a dot.


https://reviews.llvm.org/D33285

Files:
  lib/Format/BreakableToken.cpp
  unittests/Format/FormatTestComments.cpp


Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -1629,6 +1629,38 @@
"//  long",
getLLVMStyleWithColumns(20)));
 
+  // Don't reflow separate bullets in list
+  EXPECT_EQ("// - long long long\n"
+"// long\n"
+"// - long",
+format("// - long long long long\n"
+   "// - long",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("// * long long long\n"
+"// long\n"
+"// * long",
+format("// * long long long long\n"
+   "// * long",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("// + long long long\n"
+"// long\n"
+"// + long",
+format("// + long long long long\n"
+   "// + long",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("// 1. long long long\n"
+"// long\n"
+"// 2. long",
+format("// 1. long long long long\n"
+   "// 2. long",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("// -# long long long\n"
+"// long\n"
+"// -# long",
+format("// -# long long long long\n"
+   "// -# long",
+   getLLVMStyleWithColumns(20)));
+
   // Don't break or reflow after implicit string literals.
   verifyFormat("#include  // l l l\n"
" // l",
Index: lib/Format/BreakableToken.cpp
===
--- lib/Format/BreakableToken.cpp
+++ lib/Format/BreakableToken.cpp
@@ -298,15 +298,22 @@
 static bool mayReflowContent(StringRef Content) {
   Content = Content.trim(Blanks);
   // Lines starting with '@' commonly have special meaning.
-  static const SmallVector kSpecialMeaningPrefixes = {
-  "@", "TODO", "FIXME", "XXX"};
+  // Lines starting with '-', '-#', '+' or '*' are bulleted/numbered lists.
+  static const SmallVector kSpecialMeaningPrefixes = {
+  "@", "TODO", "FIXME", "XXX", "-# ", "- ", "+ ", "* " };
   bool hasSpecialMeaningPrefix = false;
   for (StringRef Prefix : kSpecialMeaningPrefixes) {
 if (Content.startswith(Prefix)) {
   hasSpecialMeaningPrefix = true;
   break;
 }
   }
+
+  // Numbered lists may also start with a number followed by '.'
+  static const char *kNumberedListPattern = "^[0-9]+\\. ";
+  hasSpecialMeaningPrefix = hasSpecialMeaningPrefix ||
+llvm::Regex(kNumberedListPattern).match(Content);
+
   // Simple heuristic for what to reflow: content should contain at least two
   // characters and either the first or second character must be
   // non-punctuation.


Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -1629,6 +1629,38 @@
"//  long",
getLLVMStyleWithColumns(20)));
 
+  // Don't reflow separate bullets in list
+  EXPECT_EQ("// - long long long\n"
+"// long\n"
+"// - long",
+format("// - long long long long\n"
+   "// - long",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("// * long long long\n"
+"// long\n"
+"// * long",
+format("// * long long long long\n"
+   "// * long",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("// + long long long\n"
+"// long\n"
+"// + long",
+format("// + long long long long\n"
+   "// + long",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("// 1. long long long\n"
+"// long\n"
+"// 2. long",
+format("// 1. long long long long\n"
+   "// 2. long",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("// -# long long long\n"
+"// long\n"
+"// -# long",
+format("// -# long long long long\n"
+   "// -# long",
+   getLLVMStyleWithColumns(20)));
+
   // Don't break or reflow after implicit string literals.
   verifyFormat("#include  // l l l\n"
" // l",
Index: lib/Format/BreakableToken.cpp

[PATCH] D33191: [analyzer] ObjCGenerics: account for __kindof specifiers met along a chain of casts.

2017-05-17 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:464
  ASTContext ) {
+  if (hasKindofArgs(StaticUpperBound)) {
+// If the upper bound type has more __kindof specs, we drop all the info,

I am concerned that this might cause regressions as other logic in this 
function is not triggered when this condition fires. For example, this would 
only be safe if Current and StaticUpperBoound are the same type apart from 
__kindof modifier.


https://reviews.llvm.org/D33191



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


[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-05-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

yaxunl wrote:
> bader wrote:
> > yaxunl wrote:
> > > Anastasia wrote:
> > > > echuraev wrote:
> > > > > yaxunl wrote:
> > > > > > Anastasia wrote:
> > > > > > > yaxunl wrote:
> > > > > > > > Anastasia wrote:
> > > > > > > > > Looks good from my side.
> > > > > > > > > 
> > > > > > > > > @yaxunl , since you originally committed this. Could you 
> > > > > > > > > please verify that changing from `SIZE_MAX` to `0` would be 
> > > > > > > > > fine.
> > > > > > > > > 
> > > > > > > > > Btw, we have a similar definition for `CLK_NULL_EVENT`.
> > > > > > > > `__PIPE_RESERVE_ID_VALID_BIT` is implementation detail and not 
> > > > > > > > part of the spec. I would suggest to remove it from this header 
> > > > > > > > file.
> > > > > > > > 
> > > > > > > > The spec only requires CLK_NULL_RESERVE_ID to be defined but 
> > > > > > > > does not define its value. Naturally a valid id starts from 0 
> > > > > > > > and increases. I don't see significant advantage to change 
> > > > > > > > CLK_NULL_RESERVE_ID from __SIZE_MAX to 0.
> > > > > > > > 
> > > > > > > > Is there any reason that this change is needed?
> > > > > > > I don't see issues to commit things outside of spec as soon as 
> > > > > > > they prefixed properly with "__".  But I agree it would be nice 
> > > > > > > to see if it's any useful and what the motivation is for having 
> > > > > > > different implementation.
> > > > > > For `__PIPE_RESERVE_ID_VALID_BIT`, it assumes that the 
> > > > > > implementation uses one specific bit of a reserve id to indicate 
> > > > > > that the reserve id is valid. Not all implementations assume that. 
> > > > > > Actually I am curious why that is needed too.
> > > > > About `CLK_NULL_RESERVE_ID`: we check that reserve id is valid if 
> > > > > significant bit equal to one. `CLK_NULL_RESERVE_ID refers to an 
> > > > > invalid reservation, so if `CLK_NULL_RESERVE_ID equal to 0, we can be 
> > > > > sure that significant bit doesn't equal to 1 and it is invalid 
> > > > > reserve id. Also it is more obviously if CLK_**NULL**_RESERVE_ID is 
> > > > > equal to 0.
> > > > > 
> > > > > What about `__PIPE_RESERVE_ID_VALID_BIT`: As I understand previous 
> > > > > implementation also assumes that one specific bit was of a reverse id 
> > > > > was used to indicate that the reserve id is valid. So, we just 
> > > > > increased reserve id size by one bit on 32-bit platforms and by 33 
> > > > > bits on 64-bit platforms. 
> > > > It is more logical to me that `CLK_NULL_RESERVE_ID` is 0, but spec 
> > > > doesn't define it of course.
> > > In our implementation, valid reserve id starts at 0 and increasing 
> > > linearly until `__SIZE_MAX-1`. This change will break our implementation.
> > > 
> > > However, we can modify our implementation to adopt this change since it 
> > > brings about benefits overall.
> > Ideally it would be great to have unified implementation, but we can define 
> > device specific value for CLK_NULL_RESERVE_ID by using ifdef directive.
> How about
> 
> ```
> __attribute__((const)) size_t __clk_null_reserve_id();
> #define CLK_NULL_RESERVE_ID __clk_null_reserve_id()
> 
> ```
> I think the spec does not require it to be compile time constant. Then each 
> library can implement its own __clk_null_reserve_id() whereas the IR is 
> target independent.
Or we only do this for SPIR and define it as target specific value for other 
targets.


https://reviews.llvm.org/D32896



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


[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-05-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

bader wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > echuraev wrote:
> > > > yaxunl wrote:
> > > > > Anastasia wrote:
> > > > > > yaxunl wrote:
> > > > > > > Anastasia wrote:
> > > > > > > > Looks good from my side.
> > > > > > > > 
> > > > > > > > @yaxunl , since you originally committed this. Could you please 
> > > > > > > > verify that changing from `SIZE_MAX` to `0` would be fine.
> > > > > > > > 
> > > > > > > > Btw, we have a similar definition for `CLK_NULL_EVENT`.
> > > > > > > `__PIPE_RESERVE_ID_VALID_BIT` is implementation detail and not 
> > > > > > > part of the spec. I would suggest to remove it from this header 
> > > > > > > file.
> > > > > > > 
> > > > > > > The spec only requires CLK_NULL_RESERVE_ID to be defined but does 
> > > > > > > not define its value. Naturally a valid id starts from 0 and 
> > > > > > > increases. I don't see significant advantage to change 
> > > > > > > CLK_NULL_RESERVE_ID from __SIZE_MAX to 0.
> > > > > > > 
> > > > > > > Is there any reason that this change is needed?
> > > > > > I don't see issues to commit things outside of spec as soon as they 
> > > > > > prefixed properly with "__".  But I agree it would be nice to see 
> > > > > > if it's any useful and what the motivation is for having different 
> > > > > > implementation.
> > > > > For `__PIPE_RESERVE_ID_VALID_BIT`, it assumes that the implementation 
> > > > > uses one specific bit of a reserve id to indicate that the reserve id 
> > > > > is valid. Not all implementations assume that. Actually I am curious 
> > > > > why that is needed too.
> > > > About `CLK_NULL_RESERVE_ID`: we check that reserve id is valid if 
> > > > significant bit equal to one. `CLK_NULL_RESERVE_ID refers to an invalid 
> > > > reservation, so if `CLK_NULL_RESERVE_ID equal to 0, we can be sure that 
> > > > significant bit doesn't equal to 1 and it is invalid reserve id. Also 
> > > > it is more obviously if CLK_**NULL**_RESERVE_ID is equal to 0.
> > > > 
> > > > What about `__PIPE_RESERVE_ID_VALID_BIT`: As I understand previous 
> > > > implementation also assumes that one specific bit was of a reverse id 
> > > > was used to indicate that the reserve id is valid. So, we just 
> > > > increased reserve id size by one bit on 32-bit platforms and by 33 bits 
> > > > on 64-bit platforms. 
> > > It is more logical to me that `CLK_NULL_RESERVE_ID` is 0, but spec 
> > > doesn't define it of course.
> > In our implementation, valid reserve id starts at 0 and increasing linearly 
> > until `__SIZE_MAX-1`. This change will break our implementation.
> > 
> > However, we can modify our implementation to adopt this change since it 
> > brings about benefits overall.
> Ideally it would be great to have unified implementation, but we can define 
> device specific value for CLK_NULL_RESERVE_ID by using ifdef directive.
How about

```
__attribute__((const)) size_t __clk_null_reserve_id();
#define CLK_NULL_RESERVE_ID __clk_null_reserve_id()

```
I think the spec does not require it to be compile time constant. Then each 
library can implement its own __clk_null_reserve_id() whereas the IR is target 
independent.


https://reviews.llvm.org/D32896



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


[PATCH] D31885: Remove TBAA information from LValues representing union members

2017-05-17 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

I posted https://reviews.llvm.org/D33284 for the change from AlignmentSource to 
LValueBaseInfo.


Repository:
  rL LLVM

https://reviews.llvm.org/D31885



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


[PATCH] D33284: [CodeGen] Propagate LValueBaseInfo instead of AlignmentSource

2017-05-17 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz created this revision.

The functions creating LValues propagated information about alignment source. 
Extend the propagated data to also include information about possible 
unrestricted aliasing. A new class LValueBaseInfo will contain both 
AlignmentSource and MayAlias info.

  

This patch should not introduce any functional changes.


Repository:
  rL LLVM

https://reviews.llvm.org/D33284

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGObjCRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1886,15 +1886,15 @@
   //======//
 
   LValue MakeAddrLValue(Address Addr, QualType T,
-AlignmentSource AlignSource = AlignmentSource::Type) {
-return LValue::MakeAddr(Addr, T, getContext(), AlignSource,
+LValueBaseInfo BaseInfo = LValueBaseInfo()) {
+return LValue::MakeAddr(Addr, T, getContext(), BaseInfo,
 CGM.getTBAAInfo(T));
   }
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
-AlignmentSource AlignSource = AlignmentSource::Type) {
+LValueBaseInfo BaseInfo = LValueBaseInfo()) {
 return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
-AlignSource, CGM.getTBAAInfo(T));
+BaseInfo, CGM.getTBAAInfo(T));
   }
 
   LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T);
@@ -1906,11 +1906,11 @@
AlignmentSource *Source = nullptr);
 
   Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy,
-  AlignmentSource *Source = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr);
   LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy);
 
   Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
-AlignmentSource *Source = nullptr);
+LValueBaseInfo *BaseInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
   /// CreateTempAlloca - This creates a alloca and inserts it into the entry
@@ -2992,8 +2992,7 @@
   /// the LLVM value representation.
   llvm::Value *EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty,
 SourceLocation Loc,
-AlignmentSource AlignSource =
-  AlignmentSource::Type,
+LValueBaseInfo BaseInfo = LValueBaseInfo(),
 llvm::MDNode *TBAAInfo = nullptr,
 QualType TBAABaseTy = QualType(),
 uint64_t TBAAOffset = 0,
@@ -3010,7 +3009,7 @@
   /// the LLVM value representation.
   void EmitStoreOfScalar(llvm::Value *Value, Address Addr,
  bool Volatile, QualType Ty,
- AlignmentSource AlignSource = AlignmentSource::Type,
+ LValueBaseInfo BaseInfo = LValueBaseInfo(),
  llvm::MDNode *TBAAInfo = nullptr, bool isInit = false,
  QualType TBAABaseTy = QualType(),
  uint64_t TBAAOffset = 0, bool isNontemporal = false);
@@ -3083,7 +3082,7 @@
   RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc);
 
   Address EmitArrayToPointerDecay(const Expr *Array,
-  AlignmentSource *AlignSource = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr);
 
   class ConstantEmission {
 llvm::PointerIntPair ValueAndIsReference;
@@ -3224,7 +3223,7 @@
   Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base,
   llvm::Value *memberPtr,
   const MemberPointerType *memberPtrType,
-  AlignmentSource *AlignSource = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr);
   RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
   ReturnValueSlot ReturnValue);
 
@@ -3765,7 +3764,7 @@
   ///   just ignore the returned alignment when it isn't from an
   ///   explicit source.
   Address EmitPointerWithAlignment(const Expr *Addr,
-   AlignmentSource *Source = nullptr);
+  

[libcxx] r303268 - Mark the copy constructor and move

2017-05-17 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed May 17 10:30:01 2017
New Revision: 303268

URL: http://llvm.org/viewvc/llvm-project?rev=303268=rev
Log:
Mark the copy constructor and move 
constructor to be constexpr. This only works when the contained type has a 
constexpr copy/move ctor.

Modified:
libcxx/trunk/include/optional

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp

Modified: libcxx/trunk/include/optional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/optional?rev=303268=303267=303268=diff
==
--- libcxx/trunk/include/optional (original)
+++ libcxx/trunk/include/optional Wed May 17 10:30:01 2017
@@ -599,8 +599,8 @@ private:
 public:
 
 _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
-_LIBCPP_INLINE_VISIBILITY optional(const optional&) = default;
-_LIBCPP_INLINE_VISIBILITY optional(optional&&) = default;
+_LIBCPP_INLINE_VISIBILITY constexpr optional(const optional&) = default;
+_LIBCPP_INLINE_VISIBILITY constexpr optional(optional&&) = default;
 _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
 
 template http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp?rev=303268=303267=303268=diff
==
--- 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
 Wed May 17 10:30:01 2017
@@ -10,7 +10,7 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(const optional& rhs);
+// constexpr optional(const optional& rhs);
 
 #include 
 #include 
@@ -152,4 +152,9 @@ int main()
 {
 test_reference_extension();
 }
+{
+constexpr std::optional o1{4};
+constexpr std::optional o2 = o1;
+static_assert( *o2 == 4, "" );
+}
 }

Modified: 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp?rev=303268=303267=303268=diff
==
--- 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
 Wed May 17 10:30:01 2017
@@ -18,7 +18,7 @@
 
 // 
 
-// optional(optional&& rhs);
+// constexpr optional(optional&& rhs);
 
 #include 
 #include 
@@ -206,4 +206,9 @@ int main()
 {
 test_reference_extension();
 }
+{
+constexpr std::optional o1{4};
+constexpr std::optional o2 = std::move(o1);
+static_assert( *o2 == 4, "" );
+}
 }


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


[PATCH] D33258: clang-cl: Fix path-based MSVC version detection

2017-05-17 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303267: clang-cl: Fix path-based MSVC version detection 
(authored by hans).

Changed prior to commit:
  https://reviews.llvm.org/D33258?vs=99213=99310#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33258

Files:
  cfe/trunk/lib/Driver/ToolChains/MSVC.cpp


Index: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
@@ -125,8 +125,15 @@
 continue;
 
   // whatever/VC/bin --> old toolchain, VC dir is toolchain dir.
-  if (llvm::sys::path::filename(PathEntry) == "bin") {
-llvm::StringRef ParentPath = llvm::sys::path::parent_path(PathEntry);
+  llvm::StringRef TestPath = PathEntry;
+  bool IsBin = llvm::sys::path::filename(TestPath).equals_lower("bin");
+  if (!IsBin) {
+// Strip any architecture subdir like "amd64".
+TestPath = llvm::sys::path::parent_path(TestPath);
+IsBin = llvm::sys::path::filename(TestPath).equals_lower("bin");
+  }
+  if (IsBin) {
+llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath);
 if (llvm::sys::path::filename(ParentPath) == "VC") {
   Path = ParentPath;
   IsVS2017OrNewer = false;


Index: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
@@ -125,8 +125,15 @@
 continue;
 
   // whatever/VC/bin --> old toolchain, VC dir is toolchain dir.
-  if (llvm::sys::path::filename(PathEntry) == "bin") {
-llvm::StringRef ParentPath = llvm::sys::path::parent_path(PathEntry);
+  llvm::StringRef TestPath = PathEntry;
+  bool IsBin = llvm::sys::path::filename(TestPath).equals_lower("bin");
+  if (!IsBin) {
+// Strip any architecture subdir like "amd64".
+TestPath = llvm::sys::path::parent_path(TestPath);
+IsBin = llvm::sys::path::filename(TestPath).equals_lower("bin");
+  }
+  if (IsBin) {
+llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath);
 if (llvm::sys::path::filename(ParentPath) == "VC") {
   Path = ParentPath;
   IsVS2017OrNewer = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r303267 - clang-cl: Fix path-based MSVC version detection

2017-05-17 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed May 17 10:27:44 2017
New Revision: 303267

URL: http://llvm.org/viewvc/llvm-project?rev=303267=rev
Log:
clang-cl: Fix path-based MSVC version detection

The code wasn't taking the architecture-specific subdirectory into
account.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/MSVC.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=303267=303266=303267=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Wed May 17 10:27:44 2017
@@ -125,8 +125,15 @@ static bool findVCToolChainViaEnvironmen
 continue;
 
   // whatever/VC/bin --> old toolchain, VC dir is toolchain dir.
-  if (llvm::sys::path::filename(PathEntry) == "bin") {
-llvm::StringRef ParentPath = llvm::sys::path::parent_path(PathEntry);
+  llvm::StringRef TestPath = PathEntry;
+  bool IsBin = llvm::sys::path::filename(TestPath).equals_lower("bin");
+  if (!IsBin) {
+// Strip any architecture subdir like "amd64".
+TestPath = llvm::sys::path::parent_path(TestPath);
+IsBin = llvm::sys::path::filename(TestPath).equals_lower("bin");
+  }
+  if (IsBin) {
+llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath);
 if (llvm::sys::path::filename(ParentPath) == "VC") {
   Path = ParentPath;
   IsVS2017OrNewer = false;


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


[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-05-17 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

yaxunl wrote:
> Anastasia wrote:
> > echuraev wrote:
> > > yaxunl wrote:
> > > > Anastasia wrote:
> > > > > yaxunl wrote:
> > > > > > Anastasia wrote:
> > > > > > > Looks good from my side.
> > > > > > > 
> > > > > > > @yaxunl , since you originally committed this. Could you please 
> > > > > > > verify that changing from `SIZE_MAX` to `0` would be fine.
> > > > > > > 
> > > > > > > Btw, we have a similar definition for `CLK_NULL_EVENT`.
> > > > > > `__PIPE_RESERVE_ID_VALID_BIT` is implementation detail and not part 
> > > > > > of the spec. I would suggest to remove it from this header file.
> > > > > > 
> > > > > > The spec only requires CLK_NULL_RESERVE_ID to be defined but does 
> > > > > > not define its value. Naturally a valid id starts from 0 and 
> > > > > > increases. I don't see significant advantage to change 
> > > > > > CLK_NULL_RESERVE_ID from __SIZE_MAX to 0.
> > > > > > 
> > > > > > Is there any reason that this change is needed?
> > > > > I don't see issues to commit things outside of spec as soon as they 
> > > > > prefixed properly with "__".  But I agree it would be nice to see if 
> > > > > it's any useful and what the motivation is for having different 
> > > > > implementation.
> > > > For `__PIPE_RESERVE_ID_VALID_BIT`, it assumes that the implementation 
> > > > uses one specific bit of a reserve id to indicate that the reserve id 
> > > > is valid. Not all implementations assume that. Actually I am curious 
> > > > why that is needed too.
> > > About `CLK_NULL_RESERVE_ID`: we check that reserve id is valid if 
> > > significant bit equal to one. `CLK_NULL_RESERVE_ID refers to an invalid 
> > > reservation, so if `CLK_NULL_RESERVE_ID equal to 0, we can be sure that 
> > > significant bit doesn't equal to 1 and it is invalid reserve id. Also it 
> > > is more obviously if CLK_**NULL**_RESERVE_ID is equal to 0.
> > > 
> > > What about `__PIPE_RESERVE_ID_VALID_BIT`: As I understand previous 
> > > implementation also assumes that one specific bit was of a reverse id was 
> > > used to indicate that the reserve id is valid. So, we just increased 
> > > reserve id size by one bit on 32-bit platforms and by 33 bits on 64-bit 
> > > platforms. 
> > It is more logical to me that `CLK_NULL_RESERVE_ID` is 0, but spec doesn't 
> > define it of course.
> In our implementation, valid reserve id starts at 0 and increasing linearly 
> until `__SIZE_MAX-1`. This change will break our implementation.
> 
> However, we can modify our implementation to adopt this change since it 
> brings about benefits overall.
Ideally it would be great to have unified implementation, but we can define 
device specific value for CLK_NULL_RESERVE_ID by using ifdef directive.


https://reviews.llvm.org/D32896



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


[PATCH] D33282: clang-format: fix prefix for doxygen comments after member

2017-05-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz created this revision.
Herald added a subscriber: klimek.

Doxygen supports putting documentation blocks after member, by adding
an additional < marker in the comment block. This patch makes sure
this marker is used in lines which are introduced by breaking the
comment.

  int foo; ///< Some very long comment.

becomes:

  int foo; ///< Some very long
   ///< comment.


https://reviews.llvm.org/D33282

Files:
  lib/Format/BreakableToken.cpp
  unittests/Format/FormatTestComments.cpp


Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -1198,6 +1198,16 @@
 format("/* long long long long\n"
" * long */",
getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("///< long long long\n"
+"///< long long\n",
+format("///< long long long long\n"
+   "///< long\n",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("//!< long long long\n"
+"//!< long long\n",
+format("//!< long long long long\n"
+   "//!< long\n",
+   getLLVMStyleWithColumns(20)));
 
   // Don't bring leading whitespace up while reflowing.
   EXPECT_EQ("/*  long long long\n"
Index: lib/Format/BreakableToken.cpp
===
--- lib/Format/BreakableToken.cpp
+++ lib/Format/BreakableToken.cpp
@@ -41,7 +41,8 @@
 }
 
 static StringRef getLineCommentIndentPrefix(StringRef Comment) {
-  static const char *const KnownPrefixes[] = {"///", "//", "//!"};
+  static const char *const KnownPrefixes[] = {
+  "///<", "//!<", "///", "//", "//!"};
   StringRef LongestPrefix;
   for (StringRef KnownPrefix : KnownPrefixes) {
 if (Comment.startswith(KnownPrefix)) {
@@ -692,6 +693,10 @@
   Prefix[i] = "/// ";
 else if (Prefix[i] == "//!")
   Prefix[i] = "//! ";
+else if (Prefix[i] == "///<")
+  Prefix[i] = "///< ";
+else if (Prefix[i] == "//!<")
+  Prefix[i] = "//!< ";
   }
 
   Tokens[i] = LineTok;


Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -1198,6 +1198,16 @@
 format("/* long long long long\n"
" * long */",
getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("///< long long long\n"
+"///< long long\n",
+format("///< long long long long\n"
+   "///< long\n",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("//!< long long long\n"
+"//!< long long\n",
+format("//!< long long long long\n"
+   "//!< long\n",
+   getLLVMStyleWithColumns(20)));
 
   // Don't bring leading whitespace up while reflowing.
   EXPECT_EQ("/*  long long long\n"
Index: lib/Format/BreakableToken.cpp
===
--- lib/Format/BreakableToken.cpp
+++ lib/Format/BreakableToken.cpp
@@ -41,7 +41,8 @@
 }
 
 static StringRef getLineCommentIndentPrefix(StringRef Comment) {
-  static const char *const KnownPrefixes[] = {"///", "//", "//!"};
+  static const char *const KnownPrefixes[] = {
+  "///<", "//!<", "///", "//", "//!"};
   StringRef LongestPrefix;
   for (StringRef KnownPrefix : KnownPrefixes) {
 if (Comment.startswith(KnownPrefix)) {
@@ -692,6 +693,10 @@
   Prefix[i] = "/// ";
 else if (Prefix[i] == "//!")
   Prefix[i] = "//! ";
+else if (Prefix[i] == "///<")
+  Prefix[i] = "///< ";
+else if (Prefix[i] == "//!<")
+  Prefix[i] = "//!< ";
   }
 
   Tokens[i] = LineTok;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33259: Don't defer to the GCC driver for linking arm-baremetal

2017-05-17 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs planned changes to this revision.
jroelofs added inline comments.



Comment at: cmake/caches/BaremetalARM.cmake:1
+set(LLVM_TARGETS_TO_BUILD ARM CACHE STRING "")
+

compnerd wrote:
> Please rename this file to `BareMetalARMv6.cmake`.  (I'm interested in the 
> suffix primarily).
My plan is to eventually add multilibs to this configuration, so while that 
makes sense short term, I don't think it makes sense long term.

With that in mind, do you still want me to rename it?



Comment at: lib/Driver/ToolChains/BareMetal.cpp:68
+  SmallString<128> Dir(getDriver().ResourceDir);
+  llvm::sys::path::append(Dir, "lib", "baremetal");
+  return Dir.str();

compnerd wrote:
> Why not just the standard `arm` directory?
There are a few differences between the stuff in the existing ones, and what is 
needed on baremetal. For example __enable_execute_stack, emutls, as well as 
anything else that assumes existence of pthreads support shouldn't be there.



Comment at: lib/Driver/ToolChains/BareMetal.cpp:74
+  SmallString<128> Dir(getDriver().ResourceDir);
+  llvm::sys::path::append(Dir, "include", "c++", "v1");
+  return Dir.str();

compnerd wrote:
> This seems wrong.  The libc++ headers should *not* be in the resource dir.  
> This should be based off of the sysroot IMO.
Oh, excellent point. I was just making that same argument a few weeks ago.



Comment at: lib/Driver/ToolChains/BareMetal.cpp:107-108
+ArgStringList ) const {
+  CmdArgs.push_back("-lc++");
+  CmdArgs.push_back("-lc++abi");
+  CmdArgs.push_back("-lunwind");

compnerd wrote:
> I think that this is a bit extreme.  We already have `-stdlib=libc++` and 
> `-stdlib=libstdc++`.  Why not just honor that?
I wasn't going for "support every possible thing out of the tin", instead 
preferring incremental development :)


https://reviews.llvm.org/D33259



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


r303265 - [Frontend] Remove unused TemporaryFiles

2017-05-17 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Wed May 17 09:51:44 2017
New Revision: 303265

URL: http://llvm.org/viewvc/llvm-project?rev=303265=rev
Log:
[Frontend] Remove unused TemporaryFiles

Summary:
OnDiskData.TemporaryFiles is filled only by ASTUnit::addTemporaryFile, which is
dead. Also these files are used nowhere in the frontend nor in libclang.

Reviewers: bkramer, ilya-biryukov

Reviewed By: bkramer, ilya-biryukov

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=303265=303264=303265=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Wed May 17 09:51:44 2017
@@ -419,7 +419,6 @@ private:
   
   explicit ASTUnit(bool MainFileIsAST);
 
-  void CleanTemporaryFiles();
   bool Parse(std::shared_ptr PCHContainerOps,
  std::unique_ptr OverrideMainBuffer);
 
@@ -530,11 +529,6 @@ public:
   ASTMutationListener *getASTMutationListener();
   ASTDeserializationListener *getDeserializationListener();
 
-  /// \brief Add a temporary file that the ASTUnit depends on.
-  ///
-  /// This file will be erased when the ASTUnit is destroyed.
-  void addTemporaryFile(StringRef TempFile);
-
   bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
 
   bool getOwnsRemappedFileBuffers() const { return OwnsRemappedFileBuffers; }

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=303265=303264=303265=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Wed May 17 09:51:44 2017
@@ -84,13 +84,6 @@ namespace {
 /// \brief The file in which the precompiled preamble is stored.
 std::string PreambleFile;
 
-/// \brief Temporary files that should be removed when the ASTUnit is
-/// destroyed.
-SmallVector TemporaryFiles;
-
-/// \brief Erase temporary files.
-void CleanTemporaryFiles();
-
 /// \brief Erase the preamble file.
 void CleanPreambleFile();
 
@@ -163,12 +156,6 @@ static const std::string 
   return getOnDiskData(AU).PreambleFile;  
 }
 
-void OnDiskData::CleanTemporaryFiles() {
-  for (StringRef File : TemporaryFiles)
-llvm::sys::fs::remove(File);
-  TemporaryFiles.clear();
-}
-
 void OnDiskData::CleanPreambleFile() {
   if (!PreambleFile.empty()) {
 llvm::sys::fs::remove(PreambleFile);
@@ -177,7 +164,6 @@ void OnDiskData::CleanPreambleFile() {
 }
 
 void OnDiskData::Cleanup() {
-  CleanTemporaryFiles();
   CleanPreambleFile();
 }
 
@@ -194,14 +180,6 @@ void ASTUnit::clearFileLevelDecls() {
   llvm::DeleteContainerSeconds(FileDecls);
 }
 
-void ASTUnit::CleanTemporaryFiles() {
-  getOnDiskData(this).CleanTemporaryFiles();
-}
-
-void ASTUnit::addTemporaryFile(StringRef TempFile) {
-  getOnDiskData(this).TemporaryFiles.push_back(TempFile);
-}
-
 /// \brief After failing to build a precompiled preamble (due to
 /// errors in the source that occurs in the preamble), the number of
 /// reparses during which we'll skip even trying to precompile the
@@ -1100,7 +1078,6 @@ bool ASTUnit::Parse(std::shared_ptrhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33270: [Frontend] Remove unused TemporaryFiles

2017-05-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303265: [Frontend] Remove unused TemporaryFiles (authored by 
krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D33270?vs=99263=99306#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33270

Files:
  cfe/trunk/include/clang/Frontend/ASTUnit.h
  cfe/trunk/lib/Frontend/ASTUnit.cpp


Index: cfe/trunk/include/clang/Frontend/ASTUnit.h
===
--- cfe/trunk/include/clang/Frontend/ASTUnit.h
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h
@@ -419,7 +419,6 @@
   
   explicit ASTUnit(bool MainFileIsAST);
 
-  void CleanTemporaryFiles();
   bool Parse(std::shared_ptr PCHContainerOps,
  std::unique_ptr OverrideMainBuffer);
 
@@ -530,11 +529,6 @@
   ASTMutationListener *getASTMutationListener();
   ASTDeserializationListener *getDeserializationListener();
 
-  /// \brief Add a temporary file that the ASTUnit depends on.
-  ///
-  /// This file will be erased when the ASTUnit is destroyed.
-  void addTemporaryFile(StringRef TempFile);
-
   bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
 
   bool getOwnsRemappedFileBuffers() const { return OwnsRemappedFileBuffers; }
Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -84,13 +84,6 @@
 /// \brief The file in which the precompiled preamble is stored.
 std::string PreambleFile;
 
-/// \brief Temporary files that should be removed when the ASTUnit is
-/// destroyed.
-SmallVector TemporaryFiles;
-
-/// \brief Erase temporary files.
-void CleanTemporaryFiles();
-
 /// \brief Erase the preamble file.
 void CleanPreambleFile();
 
@@ -163,21 +156,14 @@
   return getOnDiskData(AU).PreambleFile;  
 }
 
-void OnDiskData::CleanTemporaryFiles() {
-  for (StringRef File : TemporaryFiles)
-llvm::sys::fs::remove(File);
-  TemporaryFiles.clear();
-}
-
 void OnDiskData::CleanPreambleFile() {
   if (!PreambleFile.empty()) {
 llvm::sys::fs::remove(PreambleFile);
 PreambleFile.clear();
   }
 }
 
 void OnDiskData::Cleanup() {
-  CleanTemporaryFiles();
   CleanPreambleFile();
 }
 
@@ -194,14 +180,6 @@
   llvm::DeleteContainerSeconds(FileDecls);
 }
 
-void ASTUnit::CleanTemporaryFiles() {
-  getOnDiskData(this).CleanTemporaryFiles();
-}
-
-void ASTUnit::addTemporaryFile(StringRef TempFile) {
-  getOnDiskData(this).TemporaryFiles.push_back(TempFile);
-}
-
 /// \brief After failing to build a precompiled preamble (due to
 /// errors in the source that occurs in the preamble), the number of
 /// reparses during which we'll skip even trying to precompile the
@@ -1100,7 +1078,6 @@
   // Clear out old caches and data.
   TopLevelDecls.clear();
   clearFileLevelDecls();
-  CleanTemporaryFiles();
 
   if (!OverrideMainBuffer) {
 checkAndRemoveNonDriverDiags(StoredDiagnostics);


Index: cfe/trunk/include/clang/Frontend/ASTUnit.h
===
--- cfe/trunk/include/clang/Frontend/ASTUnit.h
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h
@@ -419,7 +419,6 @@
   
   explicit ASTUnit(bool MainFileIsAST);
 
-  void CleanTemporaryFiles();
   bool Parse(std::shared_ptr PCHContainerOps,
  std::unique_ptr OverrideMainBuffer);
 
@@ -530,11 +529,6 @@
   ASTMutationListener *getASTMutationListener();
   ASTDeserializationListener *getDeserializationListener();
 
-  /// \brief Add a temporary file that the ASTUnit depends on.
-  ///
-  /// This file will be erased when the ASTUnit is destroyed.
-  void addTemporaryFile(StringRef TempFile);
-
   bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
 
   bool getOwnsRemappedFileBuffers() const { return OwnsRemappedFileBuffers; }
Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -84,13 +84,6 @@
 /// \brief The file in which the precompiled preamble is stored.
 std::string PreambleFile;
 
-/// \brief Temporary files that should be removed when the ASTUnit is
-/// destroyed.
-SmallVector TemporaryFiles;
-
-/// \brief Erase temporary files.
-void CleanTemporaryFiles();
-
 /// \brief Erase the preamble file.
 void CleanPreambleFile();
 
@@ -163,21 +156,14 @@
   return getOnDiskData(AU).PreambleFile;  
 }
 
-void OnDiskData::CleanTemporaryFiles() {
-  for (StringRef File : TemporaryFiles)
-llvm::sys::fs::remove(File);
-  TemporaryFiles.clear();
-}
-
 void OnDiskData::CleanPreambleFile() {
   if (!PreambleFile.empty()) {
 llvm::sys::fs::remove(PreambleFile);
 PreambleFile.clear();
   }
 }
 
 void OnDiskData::Cleanup() {
-  CleanTemporaryFiles();
   CleanPreambleFile();
 }
 
@@ -194,14 +180,6 @@
   

[PATCH] D32480: [clang-format] Add BinPackNamespaces option

2017-05-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added inline comments.



Comment at: include/clang/Format/Format.h:153
+  /// \endcode
+  bool AllowSemicolonAfterNamespace;
+

djasper wrote:
> While I am not entirely opposed to this feature, I think it should be a 
> separate patch.
I totally agree, which is why I created 2 commits; however, since they modify 
the same code (and I am new to Phabricator) I could not find a way to upload 
them separately.

Is there a way? Or should I upload one, and upload the next one once the first 
one has been accepted?


https://reviews.llvm.org/D32480



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


[PATCH] D33270: [Frontend] Remove unused TemporaryFiles

2017-05-17 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.

Kill it :)


https://reviews.llvm.org/D33270



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


[clang-tools-extra] r303264 - Change getChecksFilter() interface to hide implementation details.

2017-05-17 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed May 17 09:39:47 2017
New Revision: 303264

URL: http://llvm.org/viewvc/llvm-project?rev=303264=rev
Log:
Change getChecksFilter() interface to hide implementation details.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/ClangTidyModule.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=303264=303263=303264=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Wed May 17 09:39:47 2017
@@ -302,7 +302,7 @@ static void setStaticAnalyzerCheckerOpts
 
 typedef std::vector> CheckersList;
 
-static CheckersList getCheckersControlList(GlobList ) {
+static CheckersList getCheckersControlList(ClangTidyContext ) {
   CheckersList List;
 
   const auto  =
@@ -310,7 +310,7 @@ static CheckersList getCheckersControlLi
   bool AnalyzerChecksEnabled = false;
   for (StringRef CheckName : RegisteredCheckers) {
 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + 
CheckName).str());
-AnalyzerChecksEnabled |= Filter.contains(ClangTidyCheckName);
+AnalyzerChecksEnabled |= Context.isCheckEnabled(ClangTidyCheckName);
   }
 
   if (!AnalyzerChecksEnabled)
@@ -324,8 +324,10 @@ static CheckersList getCheckersControlLi
   for (StringRef CheckName : RegisteredCheckers) {
 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + 
CheckName).str());
 
-if (CheckName.startswith("core") || Filter.contains(ClangTidyCheckName))
+if (CheckName.startswith("core") ||
+Context.isCheckEnabled(ClangTidyCheckName)) {
   List.emplace_back(CheckName, true);
+}
   }
   return List;
 }
@@ -371,8 +373,7 @@ ClangTidyASTConsumerFactory::CreateASTCo
   AnalyzerOptions->Config["cfg-temporary-dtors"] =
   Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false";
 
-  GlobList  = Context.getChecksFilter();
-  AnalyzerOptions->CheckersControlList = getCheckersControlList(Filter);
+  AnalyzerOptions->CheckersControlList = getCheckersControlList(Context);
   if (!AnalyzerOptions->CheckersControlList.empty()) {
 setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
 AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
@@ -391,13 +392,12 @@ ClangTidyASTConsumerFactory::CreateASTCo
 
 std::vector ClangTidyASTConsumerFactory::getCheckNames() {
   std::vector CheckNames;
-  GlobList  = Context.getChecksFilter();
   for (const auto  : *CheckFactories) {
-if (Filter.contains(CheckFactory.first))
+if (Context.isCheckEnabled(CheckFactory.first))
   CheckNames.push_back(CheckFactory.first);
   }
 
-  for (const auto  : getCheckersControlList(Filter))
+  for (const auto  : getCheckersControlList(Context))
 CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
 
   std::sort(CheckNames.begin(), CheckNames.end());

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=303264=303263=303264=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Wed May 
17 09:39:47 2017
@@ -214,14 +214,14 @@ ClangTidyOptions ClangTidyContext::getOp
 
 void ClangTidyContext::setCheckProfileData(ProfileData *P) { Profile = P; }
 
-GlobList ::getChecksFilter() {
+bool ClangTidyContext::isCheckEnabled(StringRef CheckName) const {
   assert(CheckFilter != nullptr);
-  return *CheckFilter;
+  return CheckFilter->contains(CheckName);
 }
 
-GlobList ::getWarningAsErrorFilter() {
+bool ClangTidyContext::treatAsError(StringRef CheckName) const {
   assert(WarningAsErrorFilter != nullptr);
-  return *WarningAsErrorFilter;
+  return WarningAsErrorFilter->contains(CheckName);
 }
 
 /// \brief Store a \c ClangTidyError.
@@ -252,7 +252,7 @@ ClangTidyDiagnosticConsumer::ClangTidyDi
 void ClangTidyDiagnosticConsumer::finalizeLastError() {
   if (!Errors.empty()) {
 ClangTidyError  = Errors.back();
-if (!Context.getChecksFilter().contains(Error.DiagnosticName) &&
+if (!Context.isCheckEnabled(Error.DiagnosticName) &&
 Error.DiagLevel != ClangTidyError::Error) {
   ++Context.Stats.ErrorsIgnoredCheckFilter;
   Errors.pop_back();
@@ -384,9 +384,8 @@ void ClangTidyDiagnosticConsumer::Handle
   LastErrorRelatesToUserCode = true;
   LastErrorPassesLineFilter = true;
 }
-bool IsWarningAsError =
-DiagLevel == DiagnosticsEngine::Warning &&
-

[PATCH] D33191: [analyzer] ObjCGenerics: account for __kindof specifiers met along a chain of casts.

2017-05-17 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D33191#756174, @NoQ wrote:

> @Gábor: I didn't want to bother you with this, but i'm not entirely sure 
> about how to deal with these false positives; since you're the original 
> author of this check, if you see anything obviously wrong here please comment 
> on me :)


I do not see anything obviously wrong. Of course this approach is very 
conservative, but in order to do it less conservatively probably we would need 
to store the type information separately for every type argument. Converting to 
that approach would be a lot of work, and it might make the check more complex.


https://reviews.llvm.org/D33191



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


[clang-tools-extra] r303263 - [clang-tidy] Replace matchesName with hasName where no regex is needed

2017-05-17 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed May 17 09:39:39 2017
New Revision: 303263

URL: http://llvm.org/viewvc/llvm-project?rev=303263=rev
Log:
[clang-tidy] Replace matchesName with hasName where no regex is needed

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSharedCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSharedCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSharedCheck.cpp?rev=303263=303262=303263=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSharedCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSharedCheck.cpp Wed May 17 
09:39:39 2017
@@ -21,7 +21,7 @@ MakeSharedCheck::MakeSharedCheck(StringR
 MakeSharedCheck::SmartPtrTypeMatcher
 MakeSharedCheck::getSmartPointerTypeMatcher() const {
   return qualType(hasDeclaration(classTemplateSpecializationDecl(
-  matchesName("::std::shared_ptr"), templateArgumentCountIs(1),
+  hasName("::std::shared_ptr"), templateArgumentCountIs(1),
   hasTemplateArgument(
   0, templateArgument(refersToType(qualType().bind(PointerType)));
 }

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp?rev=303263=303262=303263=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp Wed May 17 
09:39:39 2017
@@ -22,17 +22,17 @@ MakeUniqueCheck::MakeUniqueCheck(StringR
 MakeUniqueCheck::SmartPtrTypeMatcher
 MakeUniqueCheck::getSmartPointerTypeMatcher() const {
   return qualType(hasDeclaration(classTemplateSpecializationDecl(
-  matchesName("::std::unique_ptr"), templateArgumentCountIs(2),
+  hasName("::std::unique_ptr"), templateArgumentCountIs(2),
   hasTemplateArgument(
   0, templateArgument(refersToType(qualType().bind(PointerType,
   hasTemplateArgument(
-  1, templateArgument(refersToType(
- qualType(hasDeclaration(classTemplateSpecializationDecl(
- matchesName("::std::default_delete"),
- templateArgumentCountIs(1),
- hasTemplateArgument(
- 0, templateArgument(refersToType(qualType(
-equalsBoundNode(PointerType));
+  1,
+  templateArgument(refersToType(
+  qualType(hasDeclaration(classTemplateSpecializationDecl(
+  hasName("::std::default_delete"), templateArgumentCountIs(1),
+  hasTemplateArgument(
+  0, templateArgument(refersToType(
+ 
qualType(equalsBoundNode(PointerType));
 }
 
 } // namespace modernize


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


[PATCH] D32437: [analyzer] Nullability: fix a crash when adding notes inside a synthesized property accessor.

2017-05-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 99300.
NoQ added a comment.
Herald added a subscriber: xazax.hun.

Automatically pop up from bodyfarm-originated code in 
`PathDiagnosticLocation::getStmt()`.

Avoid putting "Calling..." and "Returning..." notes on Objective-C 
auto-synthesized property calls, because they would never call visible code 
later.

Test the newly added path notes.


https://reviews.llvm.org/D32437

Files:
  include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/nullability-notes.m

Index: test/Analysis/nullability-notes.m
===
--- /dev/null
+++ test/Analysis/nullability-notes.m
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-output=text -verify %s
+
+#include "Inputs/system-header-simulator-for-nullability.h"
+
+void takesNonnull(NSObject *_Nonnull y);
+
+@interface ClassWithProperties: NSObject
+@property(copy, nullable) NSObject *x;
+-(void) method;
+@end;
+@implementation ClassWithProperties
+-(void) method {
+  // no-crash
+  NSObject *x = self.x; // expected-note{{Nullability 'nullable' is inferred}}
+  takesNonnull(x); // expected-warning{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
+   // expected-note@-1{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
+}
+@end
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -695,6 +695,18 @@
 }
 
 const Stmt *PathDiagnosticLocation::getStmt(const ExplodedNode *N) {
+  // We cannot place diagnostics on autosynthesized code.
+  // Put them onto the call site through which we jumped into autosynthesized
+  // code for the first time.
+  const LocationContext *LC = N->getLocationContext();
+  if (LC->getAnalysisDeclContext()->isBodyAutosynthesized()) {
+const LocationContext *ParentLC = LC->getParent();
+while (ParentLC->getAnalysisDeclContext()->isBodyAutosynthesized()) {
+  LC = ParentLC;
+  ParentLC = LC->getParent();
+}
+return LC->getCurrentStackFrame()->getCallSite();
+  }
   ProgramPoint P = N->getLocation();
   if (Optional SP = P.getAs())
 return SP->getStmt();
@@ -912,6 +924,12 @@
 
   callEnterWithin = PathDiagnosticLocation::createBegin(Callee, SM);
   callEnter = getLocationForCaller(CalleeCtx, CE.getLocationContext(), SM);
+
+  // Otherwise IsCalleeAnAutosynthesizedPropertyAccessor defaults to false.
+  if (const ObjCMethodDecl *MD = dyn_cast(Callee))
+IsCalleeAnAutosynthesizedPropertyAccessor = (
+MD->isPropertyAccessor() &&
+CalleeCtx->getAnalysisDeclContext()->isBodyAutosynthesized());
 }
 
 static inline void describeClass(raw_ostream , const CXXRecordDecl *D,
@@ -986,7 +1004,7 @@
 
 std::shared_ptr
 PathDiagnosticCallPiece::getCallEnterEvent() const {
-  if (!Callee)
+  if (!Callee || IsCalleeAnAutosynthesizedPropertyAccessor)
 return nullptr;
 
   SmallString<256> buf;
@@ -1020,7 +1038,7 @@
 
 std::shared_ptr
 PathDiagnosticCallPiece::getCallExitEvent() const {
-  if (NoExit)
+  if (NoExit || IsCalleeAnAutosynthesizedPropertyAccessor)
 return nullptr;
 
   SmallString<256> buf;
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -326,7 +326,7 @@
 
   // Retrieve the associated statement.
   const Stmt *S = TrackedNullab->getNullabilitySource();
-  if (!S) {
+  if (!S || S->getLocStart().isInvalid()) {
 S = PathDiagnosticLocation::getStmt(N);
   }
 
Index: include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
===
--- include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -550,20 +550,26 @@
 class PathDiagnosticCallPiece : public PathDiagnosticPiece {
   PathDiagnosticCallPiece(const Decl *callerD,
   const PathDiagnosticLocation )
-: PathDiagnosticPiece(Call), Caller(callerD), Callee(nullptr),
-  NoExit(false), callReturn(callReturnPos) {}
+  : PathDiagnosticPiece(Call), Caller(callerD), Callee(nullptr),
+NoExit(false), IsCalleeAnAutosynthesizedPropertyAccessor(false),
+callReturn(callReturnPos) {}
 
   PathDiagnosticCallPiece(PathPieces , const Decl *caller)
-: PathDiagnosticPiece(Call), Caller(caller), Callee(nullptr),
-  NoExit(true), 

[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-05-17 Thread wangrunan via Phabricator via cfe-commits
iris added a comment.

In https://reviews.llvm.org/D28952#751431, @ddcc wrote:

> In https://reviews.llvm.org/D28952#750558, @iris wrote:
>
> > How can I make z3constraintmanager.cpp work in the command line?Or how to 
> > make z3 work?
>
>
> You'll need a bleeding-edge build of Clang/LLVM, since this isn't available 
> in any stable release yet. First, build or install a recent version of z3; 
> `libz3-dev` in Debian/Ubuntu may work. Pass `-DCLANG_ANALYZER_BUILD_Z3=ON` to 
> `cmake`, when building LLVM.  Then, when running `clang`, pass `-Xanalyzer 
> -analyzer-constraints=z3`.
>
> Edit: I should mention, that unless at least https://reviews.llvm.org/D28955 
> and https://reviews.llvm.org/D28953 are also applied, you probably won't see 
> any concrete improvement in precision of the static analyzer, but only a 
> slowdown in performance.


Thank you for helping me build clang with z3.I have already applied the above 
updating.But now I have another question, when running clang with '-Xanalyzer 
-analyzer-constraints=z3' there is always be a fatal error and I don't know 
whether it is right to use a command like 'clang -Xanalyzer 
-analyzer-constraints=z3 -analyzer-checker=debug.DumpExplodedGraph test.cpp-' 
to get the ExplodedGraph which is analyzed by z3constraint?Sorry to bother.


Repository:
  rL LLVM

https://reviews.llvm.org/D28952



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


[PATCH] D33273: Recommit "[include-fixer] Don't throw exception when parsing unknown ar… …guments in vim script."

2017-05-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303260: Recommit "[include-fixer] Don't throw exception when 
parsing unknown ar…… (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D33273?vs=99275=99298#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33273

Files:
  clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py


Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
@@ -136,7 +136,12 @@
   help='clang-include-fixer input format.')
   parser.add_argument('-input', default='',
   help='String to initialize the database.')
-  args = parser.parse_args()
+  # Don't throw exception when parsing unknown arguements to make the script
+  # work in neovim.
+  # Neovim (at least v0.2.1) somehow mangles the sys.argv in a weird way: it
+  # will pass additional arguments (e.g. "-c script_host.py") to sys.argv,
+  # which makes the script fail.
+  args, _ = parser.parse_known_args()
 
   # Get the current text.
   buf = vim.current.buffer


Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
@@ -136,7 +136,12 @@
   help='clang-include-fixer input format.')
   parser.add_argument('-input', default='',
   help='String to initialize the database.')
-  args = parser.parse_args()
+  # Don't throw exception when parsing unknown arguements to make the script
+  # work in neovim.
+  # Neovim (at least v0.2.1) somehow mangles the sys.argv in a weird way: it
+  # will pass additional arguments (e.g. "-c script_host.py") to sys.argv,
+  # which makes the script fail.
+  args, _ = parser.parse_known_args()
 
   # Get the current text.
   buf = vim.current.buffer
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33278: [LLVM][x86][Inline Asm] - Enum support for MS syntax

2017-05-17 Thread Matan via Phabricator via cfe-commits
mharoush created this revision.

This patch enables the usage of constant Enum identifiers within Microsoft 
style inline assembly statements.

part 2 out of 2.
[https://reviews.llvm.org/D33277]


Repository:
  rL LLVM

https://reviews.llvm.org/D33278

Files:
  include/llvm/MC/MCParser/MCAsmParser.h
  lib/Target/X86/AsmParser/X86AsmParser.cpp

Index: lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -718,7 +718,8 @@
   ParseIntelSegmentOverride(unsigned SegReg, SMLoc Start, unsigned Size);
   std::unique_ptr ParseRoundingModeOp(SMLoc Start, SMLoc End);
   bool ParseIntelNamedOperator(StringRef Name, IntelExprStateMachine );
-  bool ParseIntelExpression(IntelExprStateMachine , SMLoc );
+  bool ParseIntelExpression(IntelExprStateMachine , SMLoc , 
+bool );
   std::unique_ptr
   ParseIntelBracExpression(unsigned SegReg, SMLoc Start, int64_t ImmDisp,
bool isSymbol, unsigned Size);
@@ -1306,8 +1307,9 @@
 return false;
   return true;
 }
-
-bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine , SMLoc ) {
+bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine , SMLoc , 
+bool ) {
+  ReplaceEnumIdentifier = false;
   MCAsmParser  = getParser();
   const AsmToken  = Parser.getTok();
 
@@ -1368,11 +1370,40 @@
 PrevTK == AsmToken::RBrac) {
   return false;
   } else {
-InlineAsmIdentifierInfo  = SM.getIdentifierInfo();
+InlineAsmIdentifierInfo Info;
+Info.clear();
 if (ParseIntelIdentifier(Val, Identifier, Info,
  /*Unevaluated=*/false, End))
   return true;
-SM.onIdentifierExpr(Val, Identifier);
+// Check if the parsed identifier was a constant Integer. Here we 
+// assume Val is of type MCConstantExpr only when it is safe to replace
+// the identifier with its constant value.
+if (const MCConstantExpr *CE = 
+dyn_cast_or_null(Val)) {
+  StringRef ErrMsg;
+  // SM should treat the value as it would an explicit integer in the 
+  // expression.
+  if(SM.onInteger(CE->getValue(), ErrMsg)) 
+return Error(IdentLoc, ErrMsg);
+  // In case we are called on a bracketed expression,
+  if (isParsingInlineAsm() && SM.getAddImmPrefix()) {
+// A single rewrite of the integer value is preformed for each enum
+// identifier. This is only done when we are inside a bracketed 
+// expression in order to match the behavior for the equivalent 
+// integer tokens.
+size_t Len = End.getPointer() - IdentLoc.getPointer();
+InstInfo->AsmRewrites->emplace_back(AOK_Imm, IdentLoc,Len, 
+CE->getValue());
+break;
+  }
+  // Set force rewrite flag only when not bracketed expression.
+  ReplaceEnumIdentifier = true;
+} else {
+  // Notify the SM a variable identifier was found.
+  InlineAsmIdentifierInfo  = SM.getIdentifierInfo();
+  	  SMInfo = Info;
+  SM.onIdentifierExpr(Val, Identifier);
+}
   }
   break;
 }
@@ -1452,7 +1483,8 @@
   // may have already parsed an immediate displacement before the bracketed
   // expression.
   IntelExprStateMachine SM(ImmDisp, /*StopOnLBrac=*/false, /*AddImmPrefix=*/true);
-  if (ParseIntelExpression(SM, End))
+  bool ReplaceEnumIdentifier;
+  if (ParseIntelExpression(SM, End, ReplaceEnumIdentifier))
 return nullptr;
 
   const MCExpr *Disp = nullptr;
@@ -1559,7 +1591,15 @@
   // failed parsing.
   assert((End.getPointer() == EndPtr || !Result) &&
  "frontend claimed part of a token?");
-
+  
+  // Try to evaluate the result as a constant integer (enum identifier).
+  int64_t ConstVal = 0;
+  if (SemaCallback->EvaluateLookupAsEnum(Result, ConstVal)) {
+// By creating MCConstantExpr we let the user of Val know it is safe
+// to use as an explicit constant with value = ConstVal.
+Val = MCConstantExpr::create(ConstVal, getParser().getContext());
+return false;
+  }
   // If the identifier lookup was unsuccessful, assume that we are dealing with
   // a label.
   if (!Result) {
@@ -1852,18 +1892,21 @@
   AsmToken StartTok = Tok;
   IntelExprStateMachine SM(/*Imm=*/0, /*StopOnLBrac=*/true,
/*AddImmPrefix=*/false);
-  if (ParseIntelExpression(SM, End))
+  // The parsed expression may contain enum identifier tokens which we must 
+  // replace, ReplaceEnumIdentifier flag lets us know when to force rewrite.
+  bool ReplaceEnumIdentifier;
+  if (ParseIntelExpression(SM, End, ReplaceEnumIdentifier))
 return nullptr;
-
   bool isSymbol = SM.getSym() && SM.getSym()->getKind() != 

[PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-05-17 Thread Matan via Phabricator via cfe-commits
mharoush created this revision.
mharoush added a project: clang-c.
Herald added a subscriber: eraman.

This patch enables the usage of constant Enum identifiers within Microsoft 
style inline assembly statements.

part 1 out of 2.


Repository:
  rL LLVM

https://reviews.llvm.org/D33277

Files:
  lib/Parse/ParseStmtAsm.cpp
  test/CodeGen/x86-ms-inline-asm-enum_feature.cpp


Index: lib/Parse/ParseStmtAsm.cpp
===
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -94,6 +94,23 @@
 return Info.OpDecl;
   }
 
+  // Try to evaluate the inline asm identifier lookup result as an
+  // enumerated type. This method expects LookupResult to be the
+  // result of a call to LookupInlineAsmIdentifier.
+  bool EvaluateLookupAsEnum(void *LookupResult, int64_t ) {
+if (!LookupResult) return false;
+Expr *Res = static_cast (LookupResult);
+if (Res && isa(Res->getType())) {
+  Expr::EvalResult EvlResult;
+  if (Res->EvaluateAsRValue(EvlResult,
+  TheParser.getActions().getASTContext())) {
+Result = EvlResult.Val.getInt().getExtValue();
+return true;
+  }
+}
+return false;
+  }
+
   StringRef LookupInlineAsmLabel(StringRef Identifier, llvm::SourceMgr ,
  llvm::SMLoc Location,
  bool Create) override {
Index: test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
===
--- test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
+++ test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -fasm-blocks -emit-llvm -o - | FileCheck %s
+namespace x {
+enum { A = 12 };
+namespace y {
+enum { A = 17 };
+}
+}
+
+void x86_enum_only(){
+  const int a = 0;
+  // CHECK-NOT: mov eax, [$$0]
+  __asm mov eax, [a]
+}
+
+void x86_enum_namespaces() {
+  enum { A = 1 };
+  // CHECK: mov eax, $$12
+  __asm mov eax, x::A
+  // CHECK: mov eax, $$17
+  __asm mov eax, x::y::A
+  // CHECK: mov eax, $$1
+  __asm mov eax, A
+}
+
+void x86_enum_arithmethic() {
+  enum { A = 1, B };
+  // CHECK: mov eax, $$21
+  __asm mov eax, (A + 9) * 2 + A
+  // CHECK: mov eax, $$4
+  __asm mov eax, A << 2
+  // CHECK: mov eax, $$2
+  __asm mov eax, B & 3
+  // CHECK: mov eax, $$5
+  __asm mov eax, 3 + (B & 3)
+  // CHECK: mov eax, $$8
+  __asm mov eax, 2 << A * B
+}
+
+void x86_enum_mem() {
+  int arr[4];
+  enum { A = 4, B };
+  
+  // CHECK: mov eax, [($$12 + $$9) + $$4 * $$5 + $$3 + $$3 + eax]
+  __asm { mov eax, [(x::A + 9) + A * B + 3 + 3 + eax] }
+  // CHECK: mov eax, dword ptr $$4$0
+  __asm { mov eax, [arr + A] }
+  // CHECK: mov eax, dword ptr $$8$0
+  __asm { mov eax, A[arr + A] }
+}
\ No newline at end of file


Index: lib/Parse/ParseStmtAsm.cpp
===
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -94,6 +94,23 @@
 return Info.OpDecl;
   }
 
+  // Try to evaluate the inline asm identifier lookup result as an
+  // enumerated type. This method expects LookupResult to be the
+  // result of a call to LookupInlineAsmIdentifier.
+  bool EvaluateLookupAsEnum(void *LookupResult, int64_t ) {
+if (!LookupResult) return false;
+Expr *Res = static_cast (LookupResult);
+if (Res && isa(Res->getType())) {
+  Expr::EvalResult EvlResult;
+  if (Res->EvaluateAsRValue(EvlResult,
+  TheParser.getActions().getASTContext())) {
+Result = EvlResult.Val.getInt().getExtValue();
+return true;
+  }
+}
+return false;
+  }
+
   StringRef LookupInlineAsmLabel(StringRef Identifier, llvm::SourceMgr ,
  llvm::SMLoc Location,
  bool Create) override {
Index: test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
===
--- test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
+++ test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
@@ -0,0 +1,50 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -fasm-blocks -emit-llvm -o - | FileCheck %s
+namespace x {
+enum { A = 12 };
+namespace y {
+enum { A = 17 };
+}
+}
+
+void x86_enum_only(){
+  const int a = 0;
+  // CHECK-NOT: mov eax, [$$0]
+  __asm mov eax, [a]
+}
+
+void x86_enum_namespaces() {
+  enum { A = 1 };
+  // CHECK: mov eax, $$12
+  __asm mov eax, x::A
+  // CHECK: mov eax, $$17
+  __asm mov eax, x::y::A
+  // CHECK: mov eax, $$1
+  __asm mov eax, A
+}
+
+void x86_enum_arithmethic() {
+  enum { A = 1, B };
+  // CHECK: mov eax, $$21
+  __asm mov eax, (A + 9) * 2 + A
+  // CHECK: mov eax, $$4
+  __asm mov eax, A << 2
+  // CHECK: mov eax, $$2
+  __asm mov eax, B & 3
+  // CHECK: mov eax, $$5
+  __asm mov eax, 3 + (B & 3)
+  // CHECK: mov eax, $$8
+  __asm mov eax, 2 << A * B
+}
+
+void x86_enum_mem() {
+  int arr[4];
+  enum { A = 4, B };
+  
+  // CHECK: 

[PATCH] D33053: [PowerPC] Implement vec_xxpermdi builtin.

2017-05-17 Thread Tony Jiang via Phabricator via cfe-commits
jtony updated this revision to Diff 99292.
jtony added a comment.

Address all the comments from Nemanja.


https://reviews.llvm.org/D33053

Files:
  include/clang/Basic/BuiltinsPPC.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/altivec.h
  lib/Sema/SemaChecking.cpp
  test/CodeGen/builtins-ppc-error.c
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -1691,4 +1691,60 @@
   res_vd = vec_neg(vd);
 // CHECK: fsub <2 x double> , {{%[0-9]+}}
 // CHECK-LE: fsub <2 x double> , {{%[0-9]+}}
+
+res_vd = vec_xxpermdi(vd, vd, 0);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vf = vec_xxpermdi(vf, vf, 1);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vsll = vec_xxpermdi(vsll, vsll, 2);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vull = vec_xxpermdi(vull, vull, 3);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vsi = vec_xxpermdi(vsi, vsi, 0);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vui = vec_xxpermdi(vui, vui, 1);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vss = vec_xxpermdi(vss, vss, 2);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vus = vec_xxpermdi(vus, vus, 3);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vsc = vec_xxpermdi(vsc, vsc, 0);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+
+res_vuc = vec_xxpermdi(vuc, vuc, 1);
+// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+}
+
+// The return type of the call expression may be different from the return type of the shufflevector.
+// Wrong implementation could crash the compiler, add this test case to check that and avoid ICE.
+vector int should_not_assert(vector int a, vector int b) {
+  return vec_xxpermdi(a, b, 0);
+// CHECK-LABEL: should_not_assert
+// CHECK:  bitcast <4 x i32> %{{[0-9]+}} to <2 x i64>
+// CHECK-NEXT:  bitcast <4 x i32> %{{[0-9]+}} to <2 x i64>
+// CHECK-NEXT:  shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-NEXT:  bitcast <2 x i64> %{{[0-9]+}} to <4 x i32>
+
+// CHECK-LE:  bitcast <4 x i32> %{{[0-9]+}} to <2 x i64>
+// CHECK-LE-NEXT:  bitcast <4 x i32> %{{[0-9]+}} to <2 x i64>
+// CHECK-LE-NEXT:  shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> 
+// CHECK-LE-NEXT:  bitcast <2 x i64> %{{[0-9]+}} to <4 x i32>
 }
Index: test/CodeGen/builtins-ppc-error.c
===
--- test/CodeGen/builtins-ppc-error.c
+++ test/CodeGen/builtins-ppc-error.c
@@ -13,8 +13,16 @@
 extern vector signed int vsi;
 extern vector unsigned char vuc;
 
-void testInsertWord1(void) {
+void testInsertWord(void) {
   int index = 5;
   vector unsigned char v1 = vec_insert4b(vsi, vuc, index); // expected-error {{argument to '__builtin_vsx_insertword' must be a constant integer}}
   vector unsigned long long v2 = vec_extract4b(vuc, index);   // expected-error {{argument to '__builtin_vsx_extractuword' must be a constant integer}}
 }
+
+void testXXPERMDI(void) {
+  int index = 5;
+  vec_xxpermdi(vsi); //expected-error {{too few arguments to function call, expected at least 3, have 1}}
+  vec_xxpermdi(vsi, vsi, 2, 4); //expected-error {{too many arguments to function call, expected at most 3, have 4}}
+  vec_xxpermdi(vsi, vsi, index); //expected-error {{argument 3 to '__builtin_vsx_xxpermdi' must be a 2-bit unsigned literal (i.e. 0,1,2 or 3)}}
+  vec_xxpermdi(vsi, vuc, 2); //expected-error {{first two arguments to '__builtin_vsx_xxpermdi' must have the same type}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- 

[PATCH] D33275: Keep into account if files were virtual.

2017-05-17 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.

In some cases we do not have files on disk. They are only available in the 
FileManager as virtual files and the SourceManager overrides their content.


https://reviews.llvm.org/D33275

Files:
  lib/Basic/SourceManager.cpp
  lib/Frontend/VerifyDiagnosticConsumer.cpp


Index: lib/Frontend/VerifyDiagnosticConsumer.cpp
===
--- lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -401,6 +401,9 @@
 const FileEntry *FE =
 PP->LookupFile(Pos, Filename, false, nullptr, nullptr, CurDir,
nullptr, nullptr, nullptr, nullptr);
+// Check if the file was virtual
+if (!FE)
+  FE = SM.getFileManager().getFile(Filename);
 if (!FE) {
   Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin),
diag::err_verify_missing_file) << Filename << KindStr;
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1225,8 +1225,15 @@
 static void ComputeLineNumbers(DiagnosticsEngine , ContentCache *FI,
llvm::BumpPtrAllocator ,
const SourceManager , bool ) {
-  // Note that calling 'getBuffer()' may lazily page in the file.
-  MemoryBuffer *Buffer = FI->getBuffer(Diag, SM, SourceLocation(), );
+  MemoryBuffer *Buffer = nullptr;
+  if (SM.isFileOverridden(FI->ContentsEntry))
+Buffer
+  = 
const_cast(SM).getMemoryBufferForFile(FI->ContentsEntry,
+  );
+  else
+// Note that calling 'getBuffer()' may lazily page in the file.
+Buffer = FI->getBuffer(Diag, SM, SourceLocation(), );
+
   if (Invalid)
 return;
 


Index: lib/Frontend/VerifyDiagnosticConsumer.cpp
===
--- lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -401,6 +401,9 @@
 const FileEntry *FE =
 PP->LookupFile(Pos, Filename, false, nullptr, nullptr, CurDir,
nullptr, nullptr, nullptr, nullptr);
+// Check if the file was virtual
+if (!FE)
+  FE = SM.getFileManager().getFile(Filename);
 if (!FE) {
   Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin),
diag::err_verify_missing_file) << Filename << KindStr;
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1225,8 +1225,15 @@
 static void ComputeLineNumbers(DiagnosticsEngine , ContentCache *FI,
llvm::BumpPtrAllocator ,
const SourceManager , bool ) {
-  // Note that calling 'getBuffer()' may lazily page in the file.
-  MemoryBuffer *Buffer = FI->getBuffer(Diag, SM, SourceLocation(), );
+  MemoryBuffer *Buffer = nullptr;
+  if (SM.isFileOverridden(FI->ContentsEntry))
+Buffer
+  = const_cast(SM).getMemoryBufferForFile(FI->ContentsEntry,
+  );
+  else
+// Note that calling 'getBuffer()' may lazily page in the file.
+Buffer = FI->getBuffer(Diag, SM, SourceLocation(), );
+
   if (Invalid)
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2017-05-17 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: include/clang/Format/Format.h:793
+  /// \endcode
+  bool DanglingParenthesis;
+

stringham wrote:
> djasper wrote:
> > I don't think this is a name that anyone will intuitively understand. I 
> > understand that the naming is hard here. One thing I am wondering is 
> > whether this might ever make sense unless AlignAfterOpenBracket is set to 
> > AlwaysBreak?
> > 
> > Unless that option is set, we could have both in the same file:
> > 
> >   someFunction(,
> >);
> > 
> > and
> > 
> >   someFunction(
> >   , 
> >   );
> > 
> > Is that intended, i.e. are you actively using that? Answering this is 
> > important, because it influence whether or not we actually need to add 
> > another style option and even how to implement this.
> The name was based on the configuration option that scalafmt has for their 
> automatic scala formatter, they also have an option to have the closing paren 
> on its own line and they call it `danglingParentheses`. I don't love the name 
> and am open to other options.
> 
> That's a good point about AlignAfterOpenBracket being set to AlwaysBreak. In 
> our usage we have that option set, and I'm also unsure if it makes sense 
> without AlwaysBreak.
Hm. I am not sure either. What do you think of extending the 
BracketAlignmentStyle enum with an AlwaysBreakWithDanglingParenthesis? Or 
AlwaysBreakAndWrapRParen?


https://reviews.llvm.org/D33029



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


[clang-tools-extra] r303256 - [clang-tidy] A bit of refactoring of modernize-replace-auto-ptr. NFC

2017-05-17 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed May 17 07:57:06 2017
New Revision: 303256

URL: http://llvm.org/viewvc/llvm-project?rev=303256=rev
Log:
[clang-tidy] A bit of refactoring of modernize-replace-auto-ptr. NFC

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp?rev=303256=303255=303256=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp Wed 
May 17 07:57:06 2017
@@ -69,123 +69,6 @@ AST_MATCHER(Decl, isFromStdNamespace) {
   return (Info && Info->isStr("std"));
 }
 
-/// \brief Matcher that finds auto_ptr declarations.
-static DeclarationMatcher AutoPtrDecl =
-recordDecl(hasName("auto_ptr"), isFromStdNamespace());
-
-/// \brief Matches types declared as auto_ptr.
-static TypeMatcher AutoPtrType = qualType(hasDeclaration(AutoPtrDecl));
-
-/// \brief Matcher that finds expressions that are candidates to be wrapped 
with
-/// 'std::move'.
-///
-/// Binds the id \c AutoPtrOwnershipTransferId to the expression.
-static StatementMatcher MovableArgumentMatcher =
-expr(allOf(isLValue(), hasType(AutoPtrType)))
-.bind(AutoPtrOwnershipTransferId);
-
-/// \brief Creates a matcher that finds the locations of types referring to the
-/// \c std::auto_ptr() type.
-///
-/// \code
-///   std::auto_ptr a;
-///^
-///
-///   typedef std::auto_ptr int_ptr_t;
-///^
-///
-///   std::auto_ptr fn(std::auto_ptr);
-///^ ^
-///
-///   
-/// \endcode
-TypeLocMatcher makeAutoPtrTypeLocMatcher() {
-  // Skip elaboratedType() as the named type will match soon thereafter.
-  return typeLoc(loc(qualType(AutoPtrType, unless(elaboratedType()
-  .bind(AutoPtrTokenId);
-}
-
-/// \brief Creates a matcher that finds the using declarations referring to
-/// \c std::auto_ptr.
-///
-/// \code
-///   using std::auto_ptr;
-///   ^~~
-/// \endcode
-DeclarationMatcher makeAutoPtrUsingDeclMatcher() {
-  return usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(
-   allOf(hasName("auto_ptr"), isFromStdNamespace()
-  .bind(AutoPtrTokenId);
-}
-
-/// \brief Creates a matcher that finds the \c std::auto_ptr copy-ctor and
-/// assign-operator expressions.
-///
-/// \c AutoPtrOwnershipTransferId is assigned to the argument of the 
expression,
-/// this is the part that has to be wrapped by \c std::move().
-///
-/// \code
-///   std::auto_ptr i, j;
-///   i = j;
-///   ^
-/// \endcode
-StatementMatcher makeTransferOwnershipExprMatcher() {
-  return anyOf(
-  cxxOperatorCallExpr(allOf(hasOverloadedOperatorName("="),
-callee(cxxMethodDecl(ofClass(AutoPtrDecl))),
-hasArgument(1, MovableArgumentMatcher))),
-  cxxConstructExpr(allOf(hasType(AutoPtrType), argumentCountIs(1),
- hasArgument(0, MovableArgumentMatcher;
-}
-
-/// \brief Locates the \c auto_ptr token when it is referred by a \c TypeLoc.
-///
-/// \code
-///   std::auto_ptr i;
-///^
-/// \endcode
-///
-/// The caret represents the location returned and the tildes cover the
-/// parameter \p AutoPtrTypeLoc.
-///
-/// \return An invalid \c SourceLocation if not found, otherwise the location
-/// of the beginning of the \c auto_ptr token.
-static SourceLocation locateFromTypeLoc(const TypeLoc *AutoPtrTypeLoc,
-const SourceManager ) {
-  auto TL = AutoPtrTypeLoc->getAs();
-  if (TL.isNull())
-return SourceLocation();
-
-  return TL.getTemplateNameLoc();
-}
-
-/// \brief Locates the \c auto_ptr token in using declarations.
-///
-/// \code
-///   using std::auto_ptr;
-///  ^
-/// \endcode
-///
-/// The caret represents the location returned.
-///
-/// \return An invalid \c SourceLocation if not found, otherwise the location
-/// of the beginning of the \c auto_ptr token.
-static SourceLocation locateFromUsingDecl(const UsingDecl *UsingAutoPtrDecl,
-  const SourceManager ) {
-  return UsingAutoPtrDecl->getNameInfo().getBeginLoc();
-}
-
-/// \brief Verifies that the token at \p TokenStart is 'auto_ptr'.
-static bool checkTokenIsAutoPtr(SourceLocation TokenStart,
-const SourceManager ,
-const LangOptions ) {
-  SmallVector Buffer;
-  bool Invalid = false;
-  StringRef Res = Lexer::getSpelling(TokenStart, Buffer, SM, LO, );
-
-  return (!Invalid && Res == "auto_ptr");
-}
-
 ReplaceAutoPtrCheck::ReplaceAutoPtrCheck(StringRef Name,
  

[PATCH] D32525: [clang-format] Add SpaceBeforeColon option

2017-05-17 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I have looked through the PDF you linked to, but I couldn't really find much 
about formatting. I have found one instance of a constructor initializer list, 
but there is no accompanying text saying that this is even intentional. Haven't 
found a range-based for loop. As such, I am not convinced that this option 
carries it's weight.

Also see my comment. It's very hard to even name this option without it being 
confusing to users.


https://reviews.llvm.org/D32525



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


[PATCH] D32480: [clang-format] Add BinPackNamespaces option

2017-05-17 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: include/clang/Format/Format.h:153
+  /// \endcode
+  bool AllowSemicolonAfterNamespace;
+

While I am not entirely opposed to this feature, I think it should be a 
separate patch.



Comment at: include/clang/Format/Format.h:358
+  /// \endcode
+  bool BinPackNamespaces;
+

This is not bin packing at all. Maybe CompactNamespaces? Or 
SingleLineNamespaces?

Also, could you clarify what happens if the namespaces don't fit within the 
column limit (both in the comment describing the flag and by adding tests for 
it)?


https://reviews.llvm.org/D32480



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


[PATCH] D32479: [clang-format] Add BreakConstructorInitializersBeforeColon option

2017-05-17 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Yes, turning that option into an enum seems like the better choice here.


https://reviews.llvm.org/D32479



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


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-05-17 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

The current behavior here is actually intended. If you'd like the other format, 
we probably need to add a style option. What style guide are you basing this on?




Comment at: unittests/Format/FormatTest.cpp:2476
   "bool value = a\n"
-  " + a\n"
-  " + a\n"
-  " == a\n"
-  "* b\n"
-  "+ b\n"
-  " && a\n"
-  "* a\n"
-  "> c;",
+  "   + a\n"
+  "   + a\n"

This looks very inconsistent to me.


https://reviews.llvm.org/D32478



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


[PATCH] D32477: [clang-format] Allow customizing the penalty for breaking assignment

2017-05-17 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Basically looks good, but please add a test case where the penalty is high show 
that it changes behavior.


https://reviews.llvm.org/D32477



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


[PATCH] D33273: Recommit "[include-fixer] Don't throw exception when parsing unknown ar… …guments in vim script."

2017-05-17 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

looks good, thanks!


https://reviews.llvm.org/D33273



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


[PATCH] D33238: [clang-format] Make NoLineBreakFormatter respect MustBreakBefore

2017-05-17 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Are there cases where this makes a difference? If so, add a test. If not, add 
something to the patch description to clarify.




Comment at: lib/Format/TokenAnnotator.cpp:2473
 
   // If the last token before a '}', ']', or ')' is a comma or a trailing
   // comment, the intention is to insert a line break after it in order to make

Maybe add to the comment: "Import statements, especially in JavaScript, can be 
an exception to this rule."


https://reviews.llvm.org/D33238



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


[PATCH] D33170: [X86] Adding avx512_vpopcntdq feature set and its intrinsics

2017-05-17 Thread Oren Ben Simhon via Phabricator via cfe-commits
oren_ben_simhon added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:7526
+llvm::Type *ResultType = ConvertType(E->getType());
+Value *X = EmitScalarExpr(E->getArg(0));
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::ctpop, ResultType);

craig.topper wrote:
> I'm not sure what EmitScalarExpr does, but I got think its not right for a 
> vector argument.
Vector type is considered as scalar (single value) type from the emitter point 
of view.
See also: http://llvm.org/docs/LangRef.html#single-value-types



Repository:
  rL LLVM

https://reviews.llvm.org/D33170



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


[PATCH] D33170: [X86] Adding avx512_vpopcntdq feature set and its intrinsics

2017-05-17 Thread Oren Ben Simhon via Phabricator via cfe-commits
oren_ben_simhon updated this revision to Diff 99276.
oren_ben_simhon marked an inline comment as done.
oren_ben_simhon added a comment.

Implemented comments posted until 05/16 (Thanks Craig)


Repository:
  rL LLVM

https://reviews.llvm.org/D33170

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/avx512vpopcntdqintrin.h
  lib/Headers/immintrin.h
  test/CodeGen/attr-target-x86.c
  test/CodeGen/avx512vpopcntdqintrin.c

Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -7,6 +7,7 @@
   avx2intrin.h
   avx512bwintrin.h
   avx512cdintrin.h
+  avx512vpopcntdqintrin.h
   avx512dqintrin.h
   avx512erintrin.h
   avx512fintrin.h
Index: lib/Headers/avx512vpopcntdqintrin.h
===
--- lib/Headers/avx512vpopcntdqintrin.h
+++ lib/Headers/avx512vpopcntdqintrin.h
@@ -0,0 +1,70 @@
+/*===- avx512vpopcntdqintrin.h - AVX512VPOPCNTDQ intrinsics
+ *--===
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+#ifndef __IMMINTRIN_H
+#error \
+"Never use  directly; include  instead."
+#endif
+
+#ifndef __AVX512VPOPCNTDQINTRIN_H
+#define __AVX512VPOPCNTDQINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS \
+  __attribute__((__always_inline__, __nodebug__, __target__("avx512vpopcntd"   \
+"q")))
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_popcnt_epi64(__m512i __A) {
+  return (__m512i)__builtin_ia32_vpopcntq_512((__v8di)__A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_popcnt_epi64(__m512i __W, __mmask8 __U, __m512i __A) {
+  return (__m512i)__builtin_ia32_selectq_512(
+  (__mmask8)__U, (__v8di)_mm512_popcnt_epi64(__A), (__v8di)__W);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_popcnt_epi64(__mmask8 __U, __m512i __A) {
+  return _mm512_mask_popcnt_epi64((__m512i)_mm512_setzero_si512(), __U, __A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_popcnt_epi32(__m512i __A) {
+  return (__m512i)__builtin_ia32_vpopcntd_512((__v16si)__A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_popcnt_epi32(__m512i __W, __mmask16 __U, __m512i __A) {
+  return (__m512i)__builtin_ia32_selectd_512(
+  (__mmask16)__U, (__v16si)_mm512_popcnt_epi32(__A), (__v16si)__W);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_popcnt_epi32(__mmask16 __U, __m512i __A) {
+  return _mm512_mask_popcnt_epi32((__m512i)_mm512_setzero_si512(), __U, __A);
+}
+
+#undef __DEFAULT_FN_ATTRS
+
+#endif
Index: lib/Headers/immintrin.h
===
--- lib/Headers/immintrin.h
+++ lib/Headers/immintrin.h
@@ -146,6 +146,10 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VPOPCNTDQ__)
+#include 
+#endif
+
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512DQ__)
 #include 
 #endif
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7332,39 +7332,42 @@
   AVX512PF,
   AVX512VBMI,
   AVX512IFMA,
+  AVX512VPOPCNTDQ,
   MAX
 };
 
-X86Features Feature = StringSwitch(FeatureStr)
-  .Case("cmov", X86Features::CMOV)
-  .Case("mmx", X86Features::MMX)
-  .Case("popcnt", 

[PATCH] D33273: Recommit "[include-fixer] Don't throw exception when parsing unknown ar… …guments in vim script."

2017-05-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.

To make it work in neovim.


https://reviews.llvm.org/D33273

Files:
  include-fixer/tool/clang-include-fixer.py


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -136,7 +136,12 @@
   help='clang-include-fixer input format.')
   parser.add_argument('-input', default='',
   help='String to initialize the database.')
-  args = parser.parse_args()
+  # Don't throw exception when parsing unknown arguements to make the script
+  # work in neovim.
+  # Neovim (at least v0.2.1) somehow mangles the sys.argv in a weird way: it
+  # will pass additional arguments (e.g. "-c script_host.py") to sys.argv,
+  # which makes the script fail.
+  args, _ = parser.parse_known_args()
 
   # Get the current text.
   buf = vim.current.buffer


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -136,7 +136,12 @@
   help='clang-include-fixer input format.')
   parser.add_argument('-input', default='',
   help='String to initialize the database.')
-  args = parser.parse_args()
+  # Don't throw exception when parsing unknown arguements to make the script
+  # work in neovim.
+  # Neovim (at least v0.2.1) somehow mangles the sys.argv in a weird way: it
+  # will pass additional arguments (e.g. "-c script_host.py") to sys.argv,
+  # which makes the script fail.
+  args, _ = parser.parse_known_args()
 
   # Get the current text.
   buf = vim.current.buffer
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r303250 - Constify.

2017-05-17 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed May 17 07:09:11 2017
New Revision: 303250

URL: http://llvm.org/viewvc/llvm-project?rev=303250=rev
Log:
Constify.

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=303250=303249=303250=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Wed May 17 07:09:11 2017
@@ -865,7 +865,7 @@ public:
 const FileEntry *NewFile);
 
   /// \brief Returns true if the file contents have been overridden.
-  bool isFileOverridden(const FileEntry *File) {
+  bool isFileOverridden(const FileEntry *File) const {
 if (OverriddenFilesInfo) {
   if (OverriddenFilesInfo->OverriddenFilesWithBuffer.count(File))
 return true;


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


[PATCH] D33013: Driver must return non-zero code on errors in command line

2017-05-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 99273.
sepavloff added a comment.

Moved tooling related code into separate change https://reviews.llvm.org/D33272


https://reviews.llvm.org/D33013

Files:
  include/clang/Tooling/CompilationDatabase.h
  lib/Driver/Driver.cpp
  lib/Frontend/CreateInvocationFromCommandLine.cpp
  lib/Tooling/CommonOptionsParser.cpp
  lib/Tooling/CompilationDatabase.cpp
  lib/Tooling/Tooling.cpp
  test/Driver/aarch64-cpus.c
  test/Driver/amdgpu-features.c
  test/Driver/arm-darwin-builtin.c
  test/Driver/arm-default-build-attributes.s
  test/Driver/cl-outputs.c
  test/Driver/clang_f_opts.c
  test/Driver/cuda-external-tools.cu
  test/Driver/debug-options.c
  test/Driver/gfortran.f90
  test/Driver/split-debug.h
  test/Driver/unknown-arg.c
  test/Index/index-attrs.c
  test/Index/index-attrs.cpp
  tools/driver/driver.cpp
  unittests/Driver/ToolChainTest.cpp
  unittests/Tooling/CompilationDatabaseTest.cpp

Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -504,29 +504,35 @@
 
 TEST(ParseFixedCompilationDatabase, ReturnsNullOnEmptyArgumentList) {
   int Argc = 0;
+  std::string ErrorMsg;
   std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, nullptr));
+  FixedCompilationDatabase::loadFromCommandLine(Argc, nullptr, ErrorMsg));
   EXPECT_FALSE(Database);
+  EXPECT_EQ(ErrorMsg, "error: no arguments specified\n");
   EXPECT_EQ(0, Argc);
 }
 
 TEST(ParseFixedCompilationDatabase, ReturnsNullWithoutDoubleDash) {
   int Argc = 2;
   const char *Argv[] = { "1", "2" };
+  std::string ErrorMsg;
   std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMsg));
   EXPECT_FALSE(Database);
+  EXPECT_EQ(ErrorMsg, "error: double dash not found\n");
   EXPECT_EQ(2, Argc);
 }
 
 TEST(ParseFixedCompilationDatabase, ReturnsArgumentsAfterDoubleDash) {
   int Argc = 5;
   const char *Argv[] = {
 "1", "2", "--\0no-constant-folding", "-DDEF3", "-DDEF4"
   };
+  std::string ErrorMsg;
   std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMsg));
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -543,9 +549,11 @@
 TEST(ParseFixedCompilationDatabase, ReturnsEmptyCommandLine) {
   int Argc = 3;
   const char *Argv[] = { "1", "2", "--\0no-constant-folding" };
+  std::string ErrorMsg;
   std::unique_ptr Database(
   FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -560,9 +568,11 @@
 TEST(ParseFixedCompilationDatabase, HandlesPositionalArgs) {
   const char *Argv[] = {"1", "2", "--", "-c", "somefile.cpp", "-DDEF3"};
   int Argc = sizeof(Argv) / sizeof(char*);
+  std::string ErrorMsg;
   std::unique_ptr Database(
   FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -579,9 +589,11 @@
 TEST(ParseFixedCompilationDatabase, HandlesArgv0) {
   const char *Argv[] = {"1", "2", "--", "mytool", "somefile.cpp"};
   int Argc = sizeof(Argv) / sizeof(char*);
+  std::string ErrorMsg;
   std::unique_ptr Database(
   FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
Index: unittests/Driver/ToolChainTest.cpp
===
--- unittests/Driver/ToolChainTest.cpp
+++ unittests/Driver/ToolChainTest.cpp
@@ -60,6 +60,7 @@
 
   std::unique_ptr C(TheDriver.BuildCompilation(
   {"-fsyntax-only", "--gcc-toolchain=", "foo.cpp"}));
+  EXPECT_TRUE(C);
 
   std::string S;
   {
@@ -99,6 +100,7 @@
 
   std::unique_ptr C(TheDriver.BuildCompilation(
   {"-fsyntax-only", "--gcc-toolchain=", "foo.cpp"}));
+  EXPECT_TRUE(C);
 
   std::string S;
   {
@@ -128,15 +130,24 @@
 
   Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
   InMemoryFileSystem);
+  CCDriver.setCheckInputsExist(false);
   Driver CXXDriver("/home/test/bin/clang++", "arm-linux-gnueabi", Diags,
InMemoryFileSystem);
+  CXXDriver.setCheckInputsExist(false);
   Driver CLDriver("/home/test/bin/clang-cl", "arm-linux-gnueabi", Diags,
   InMemoryFileSystem);
-
-  std::unique_ptr 

[PATCH] D33013: Driver must return non-zero code on errors in command line

2017-05-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: lib/Tooling/CompilationDatabase.cpp:208
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  UnusedInputDiagConsumer DiagClient;
+  TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), &*DiagOpts);
+  UnusedInputDiagConsumer DiagClient(DiagnosticPrinter);

alexfh wrote:
> This code is used as a library not only for command-line tools. Directly 
> using stderr is wrong in many use cases of the Tooling library. It should 
> instead somehow let the user of the library get these errors via a provided 
> DiagnosticConsumer. Not sure how to do this here without a more careful 
> reading of the code, but wanted to let you know that this change causes a 
> regression at least for clang-tidy (and likely for many other Clang tools).
This function does not have a way to report error, so its interface needs to be 
changed first. The change D33272 implements such modification.



https://reviews.llvm.org/D33013



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


[PATCH] D33272: Method loadFromCommandLine should be able to report errors

2017-05-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.

Now FixedCompilationDatabase::loadFromCommandLine has no means to report
which error occurred if it fails to create compilation object. This is
a block for implementing https://reviews.llvm.org/D33013, because after that 
change driver refuses
to create compilation if command line contains erroneous options.

This change adds additional argument to loadFromCommandLine, which is
assigned error message text if compilation object was not created. This is
the same way as other methods of CompilationDatabase report failure.


https://reviews.llvm.org/D33272

Files:
  include/clang/Tooling/CompilationDatabase.h
  lib/Frontend/CreateInvocationFromCommandLine.cpp
  lib/Tooling/CommonOptionsParser.cpp
  lib/Tooling/CompilationDatabase.cpp
  lib/Tooling/Tooling.cpp
  unittests/Tooling/CompilationDatabaseTest.cpp

Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -504,29 +504,35 @@
 
 TEST(ParseFixedCompilationDatabase, ReturnsNullOnEmptyArgumentList) {
   int Argc = 0;
+  std::string ErrorMsg;
   std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, nullptr));
+  FixedCompilationDatabase::loadFromCommandLine(Argc, nullptr, ErrorMsg));
   EXPECT_FALSE(Database);
+  EXPECT_EQ(ErrorMsg, "error: no arguments specified\n");
   EXPECT_EQ(0, Argc);
 }
 
 TEST(ParseFixedCompilationDatabase, ReturnsNullWithoutDoubleDash) {
   int Argc = 2;
   const char *Argv[] = { "1", "2" };
+  std::string ErrorMsg;
   std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMsg));
   EXPECT_FALSE(Database);
+  EXPECT_EQ(ErrorMsg, "error: double dash not found\n");
   EXPECT_EQ(2, Argc);
 }
 
 TEST(ParseFixedCompilationDatabase, ReturnsArgumentsAfterDoubleDash) {
   int Argc = 5;
   const char *Argv[] = {
 "1", "2", "--\0no-constant-folding", "-DDEF3", "-DDEF4"
   };
+  std::string ErrorMsg;
   std::unique_ptr Database(
-  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMsg));
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -543,9 +549,11 @@
 TEST(ParseFixedCompilationDatabase, ReturnsEmptyCommandLine) {
   int Argc = 3;
   const char *Argv[] = { "1", "2", "--\0no-constant-folding" };
+  std::string ErrorMsg;
   std::unique_ptr Database(
   FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -560,9 +568,11 @@
 TEST(ParseFixedCompilationDatabase, HandlesPositionalArgs) {
   const char *Argv[] = {"1", "2", "--", "-c", "somefile.cpp", "-DDEF3"};
   int Argc = sizeof(Argv) / sizeof(char*);
+  std::string ErrorMsg;
   std::unique_ptr Database(
   FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -579,9 +589,11 @@
 TEST(ParseFixedCompilationDatabase, HandlesArgv0) {
   const char *Argv[] = {"1", "2", "--", "mytool", "somefile.cpp"};
   int Argc = sizeof(Argv) / sizeof(char*);
+  std::string ErrorMsg;
   std::unique_ptr Database(
   FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
   ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMsg.empty());
   std::vector Result =
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -260,6 +260,8 @@
   Driver->setCheckInputsExist(false);
   const std::unique_ptr Compilation(
   Driver->BuildCompilation(llvm::makeArrayRef(Argv)));
+  if (!Compilation)
+return false;
   const llvm::opt::ArgStringList *const CC1Args = getCC1Arguments(
   , Compilation.get());
   if (!CC1Args) {
Index: lib/Tooling/CompilationDatabase.cpp
===
--- lib/Tooling/CompilationDatabase.cpp
+++ lib/Tooling/CompilationDatabase.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Option/Arg.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 using namespace clang;
@@ -150,23 +151,21 @@
 // options.
 class UnusedInputDiagConsumer : public DiagnosticConsumer {
 public:
-  UnusedInputDiagConsumer() : Other(nullptr) {}
-
-  // Useful for debugging, chain diagnostics to another consumer after
-  // 

[PATCH] D32700: [clang-tidy] Add misc-suspicious-memset-usage check.

2017-05-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

> The existing google-runtime-memset-zero-length check is related. It finds 
> cases when the byte count parameter is zero and offers to swap that with the 
> fill value argument. Perhaps the two could be merged while maintaining 
> backward compatibility through an alias.

I think, the checks should be merged, and there's no need to maintain the old 
behavior under the `google-runtime-memset-zero-length` alias. I'm not even sure 
we want to make this alias, as long as the new check isn't ridiculously noisy.

At this point I'd suggest that we go back to the idea of adding a separate 
module for checks that target patterns that are likely to be bugs rather than 
performance, readability or style issues. The name could be "bugprone" or 
something like this, and we could move many misc- checks there eventually.




Comment at: clang-tidy/misc/SuspiciousMemsetUsageCheck.cpp:21
+void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) {
+  const auto HasCtorOrDtor =
+  eachOf(hasMethod(cxxConstructorDecl(unless(anyOf(

rnkovacs wrote:
> xazax.hun wrote:
> > I think this might not be the best approach.
> > 
> > For example, if the constructor is compiler generated, but there is a 
> > member of the class with non-trivial constructor, we still want to warn. 
> > 
> > E.g.:
> > 
> > ```
> > struct X { X() { /* something nontrivial */ } };
> > 
> > struct Y { X x; };
> > ```
> > 
> > Maybe we should check instead whether the class is a POD? Other alternative 
> > might be something like 
> > `CXXRecordDecl::hasNonTrivialDefaultConstructor`.
> So, we had a discussion yesterday that I'll try to sum up here. The root of 
> the problem is not exactly about constructors or the object being a POD, but 
> rather about calling `memset()` on an object that is not `TriviallyCopyable`. 
> But as you suggested, this holds for `memcpy()` and `memmove()` as well, and 
> might be better placed in another check.
This logic could be either here or in a separate check (covering 'memcpy', 
'memmove' and friends), but it might even be reasonable to create a compiler 
diagnostic for this eventually (maybe after a test drive of the logic in a 
clang-tidy check).


https://reviews.llvm.org/D32700



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


r303246 - [Lexer] Ensure that the token is not an annotation token when

2017-05-17 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed May 17 06:08:36 2017
New Revision: 303246

URL: http://llvm.org/viewvc/llvm-project?rev=303246=rev
Log:
[Lexer] Ensure that the token is not an annotation token when
retrieving the identifer info for an Objective-C keyword

This commit fixes an assertion that's triggered in getIdentifier when the token
is an annotation token.

rdar://32225463

Added:
cfe/trunk/test/Modules/Inputs/objcAtKeywordMissingEnd.h
cfe/trunk/test/Modules/objc-at-keyword.m
Modified:
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/test/Modules/Inputs/module.map

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=303246=303245=303246=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed May 17 06:08:36 2017
@@ -43,6 +43,8 @@ using namespace clang;
 
 /// isObjCAtKeyword - Return true if we have an ObjC keyword identifier.
 bool Token::isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const {
+  if (isAnnotation())
+return false;
   if (IdentifierInfo *II = getIdentifierInfo())
 return II->getObjCKeywordID() == objcKey;
   return false;
@@ -50,6 +52,8 @@ bool Token::isObjCAtKeyword(tok::ObjCKey
 
 /// getObjCKeywordID - Return the ObjC keyword kind.
 tok::ObjCKeywordKind Token::getObjCKeywordID() const {
+  if (isAnnotation())
+return tok::objc_not_keyword;
   IdentifierInfo *specId = getIdentifierInfo();
   return specId ? specId->getObjCKeywordID() : tok::objc_not_keyword;
 }

Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=303246=303245=303246=diff
==
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Wed May 17 06:08:36 2017
@@ -441,3 +441,7 @@ module DebugNestedB {
   header "DebugNestedB.h"
   export *
 }
+
+module objcAtKeywordMissingEnd {
+  header "objcAtKeywordMissingEnd.h"
+}

Added: cfe/trunk/test/Modules/Inputs/objcAtKeywordMissingEnd.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objcAtKeywordMissingEnd.h?rev=303246=auto
==
--- cfe/trunk/test/Modules/Inputs/objcAtKeywordMissingEnd.h (added)
+++ cfe/trunk/test/Modules/Inputs/objcAtKeywordMissingEnd.h Wed May 17 06:08:36 
2017
@@ -0,0 +1,3 @@
+@interface MissingEnd // expected-note {{class started here}}
+
+@ // expected-error {{expected an Objective-C directive after '@'}} 
expected-error {{missing '@end'}}

Added: cfe/trunk/test/Modules/objc-at-keyword.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc-at-keyword.m?rev=303246=auto
==
--- cfe/trunk/test/Modules/objc-at-keyword.m (added)
+++ cfe/trunk/test/Modules/objc-at-keyword.m Wed May 17 06:08:36 2017
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-verify -x objective-c -fmodule-name=objcAtKeywordMissingEnd -emit-module 
%S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x 
objective-c -fmodule-name=Empty -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-verify -I %S/Inputs %s
+
+@interface X // expected-note {{class started here}}
+#pragma clang module import Empty // expected-error {{missing '@end'}}


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


[PATCH] D32524: [clang-format] Fix MatchingOpeningBlockLineIndex computation

2017-05-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

I can't think of a test case either. Thanks!


https://reviews.llvm.org/D32524



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


[clang-tools-extra] r303242 - Revert "[include-fixer] Don't throw exception when parsing unknown arguments in vim script."

2017-05-17 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed May 17 04:24:28 2017
New Revision: 303242

URL: http://llvm.org/viewvc/llvm-project?rev=303242=rev
Log:
Revert "[include-fixer] Don't throw exception when parsing unknown arguments in 
vim script."

This reverts commit r302934. It's wrong, edits the wrong file and was
committed without review.

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py?rev=303242=303241=303242=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
 (original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
 Wed May 17 04:24:28 2017
@@ -75,7 +75,7 @@ def main():
   help='path used to read a compilation database.')
   parser.add_argument('-saving-path', default='./find_all_symbols_db.yaml',
   help='result saving path')
-  args, _ = parser.parse_known_args()
+  args = parser.parse_args()
 
   db_path = 'compile_commands.json'
 


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


[PATCH] D33270: [Frontend] Remove unused TemporaryFiles

2017-05-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 99263.
krasimir added a comment.

- Remove unused method from the header file too


https://reviews.llvm.org/D33270

Files:
  include/clang/Frontend/ASTUnit.h
  lib/Frontend/ASTUnit.cpp


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -84,13 +84,6 @@
 /// \brief The file in which the precompiled preamble is stored.
 std::string PreambleFile;
 
-/// \brief Temporary files that should be removed when the ASTUnit is
-/// destroyed.
-SmallVector TemporaryFiles;
-
-/// \brief Erase temporary files.
-void CleanTemporaryFiles();
-
 /// \brief Erase the preamble file.
 void CleanPreambleFile();
 
@@ -163,21 +156,14 @@
   return getOnDiskData(AU).PreambleFile;  
 }
 
-void OnDiskData::CleanTemporaryFiles() {
-  for (StringRef File : TemporaryFiles)
-llvm::sys::fs::remove(File);
-  TemporaryFiles.clear();
-}
-
 void OnDiskData::CleanPreambleFile() {
   if (!PreambleFile.empty()) {
 llvm::sys::fs::remove(PreambleFile);
 PreambleFile.clear();
   }
 }
 
 void OnDiskData::Cleanup() {
-  CleanTemporaryFiles();
   CleanPreambleFile();
 }
 
@@ -194,14 +180,6 @@
   llvm::DeleteContainerSeconds(FileDecls);
 }
 
-void ASTUnit::CleanTemporaryFiles() {
-  getOnDiskData(this).CleanTemporaryFiles();
-}
-
-void ASTUnit::addTemporaryFile(StringRef TempFile) {
-  getOnDiskData(this).TemporaryFiles.push_back(TempFile);
-}
-
 /// \brief After failing to build a precompiled preamble (due to
 /// errors in the source that occurs in the preamble), the number of
 /// reparses during which we'll skip even trying to precompile the
@@ -1100,7 +1078,6 @@
   // Clear out old caches and data.
   TopLevelDecls.clear();
   clearFileLevelDecls();
-  CleanTemporaryFiles();
 
   if (!OverrideMainBuffer) {
 checkAndRemoveNonDriverDiags(StoredDiagnostics);
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -419,7 +419,6 @@
   
   explicit ASTUnit(bool MainFileIsAST);
 
-  void CleanTemporaryFiles();
   bool Parse(std::shared_ptr PCHContainerOps,
  std::unique_ptr OverrideMainBuffer);
 
@@ -530,11 +529,6 @@
   ASTMutationListener *getASTMutationListener();
   ASTDeserializationListener *getDeserializationListener();
 
-  /// \brief Add a temporary file that the ASTUnit depends on.
-  ///
-  /// This file will be erased when the ASTUnit is destroyed.
-  void addTemporaryFile(StringRef TempFile);
-
   bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
 
   bool getOwnsRemappedFileBuffers() const { return OwnsRemappedFileBuffers; }


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -84,13 +84,6 @@
 /// \brief The file in which the precompiled preamble is stored.
 std::string PreambleFile;
 
-/// \brief Temporary files that should be removed when the ASTUnit is
-/// destroyed.
-SmallVector TemporaryFiles;
-
-/// \brief Erase temporary files.
-void CleanTemporaryFiles();
-
 /// \brief Erase the preamble file.
 void CleanPreambleFile();
 
@@ -163,21 +156,14 @@
   return getOnDiskData(AU).PreambleFile;  
 }
 
-void OnDiskData::CleanTemporaryFiles() {
-  for (StringRef File : TemporaryFiles)
-llvm::sys::fs::remove(File);
-  TemporaryFiles.clear();
-}
-
 void OnDiskData::CleanPreambleFile() {
   if (!PreambleFile.empty()) {
 llvm::sys::fs::remove(PreambleFile);
 PreambleFile.clear();
   }
 }
 
 void OnDiskData::Cleanup() {
-  CleanTemporaryFiles();
   CleanPreambleFile();
 }
 
@@ -194,14 +180,6 @@
   llvm::DeleteContainerSeconds(FileDecls);
 }
 
-void ASTUnit::CleanTemporaryFiles() {
-  getOnDiskData(this).CleanTemporaryFiles();
-}
-
-void ASTUnit::addTemporaryFile(StringRef TempFile) {
-  getOnDiskData(this).TemporaryFiles.push_back(TempFile);
-}
-
 /// \brief After failing to build a precompiled preamble (due to
 /// errors in the source that occurs in the preamble), the number of
 /// reparses during which we'll skip even trying to precompile the
@@ -1100,7 +1078,6 @@
   // Clear out old caches and data.
   TopLevelDecls.clear();
   clearFileLevelDecls();
-  CleanTemporaryFiles();
 
   if (!OverrideMainBuffer) {
 checkAndRemoveNonDriverDiags(StoredDiagnostics);
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -419,7 +419,6 @@
   
   explicit ASTUnit(bool MainFileIsAST);
 
-  void CleanTemporaryFiles();
   bool Parse(std::shared_ptr PCHContainerOps,
  std::unique_ptr OverrideMainBuffer);
 
@@ -530,11 +529,6 @@
   ASTMutationListener *getASTMutationListener();
   

[PATCH] D33270: [Frontend] Remove unused TemporaryFiles

2017-05-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.

OnDiskData.TemporaryFiles is filled only by ASTUnit::addTemporaryFile, which is
dead. Also these files are used nowhere in the frontend nor in libclang.


https://reviews.llvm.org/D33270

Files:
  include/clang/Frontend/ASTUnit.h
  lib/Frontend/ASTUnit.cpp


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -84,13 +84,6 @@
 /// \brief The file in which the precompiled preamble is stored.
 std::string PreambleFile;
 
-/// \brief Temporary files that should be removed when the ASTUnit is
-/// destroyed.
-SmallVector TemporaryFiles;
-
-/// \brief Erase temporary files.
-void CleanTemporaryFiles();
-
 /// \brief Erase the preamble file.
 void CleanPreambleFile();
 
@@ -163,21 +156,14 @@
   return getOnDiskData(AU).PreambleFile;  
 }
 
-void OnDiskData::CleanTemporaryFiles() {
-  for (StringRef File : TemporaryFiles)
-llvm::sys::fs::remove(File);
-  TemporaryFiles.clear();
-}
-
 void OnDiskData::CleanPreambleFile() {
   if (!PreambleFile.empty()) {
 llvm::sys::fs::remove(PreambleFile);
 PreambleFile.clear();
   }
 }
 
 void OnDiskData::Cleanup() {
-  CleanTemporaryFiles();
   CleanPreambleFile();
 }
 
@@ -194,14 +180,6 @@
   llvm::DeleteContainerSeconds(FileDecls);
 }
 
-void ASTUnit::CleanTemporaryFiles() {
-  getOnDiskData(this).CleanTemporaryFiles();
-}
-
-void ASTUnit::addTemporaryFile(StringRef TempFile) {
-  getOnDiskData(this).TemporaryFiles.push_back(TempFile);
-}
-
 /// \brief After failing to build a precompiled preamble (due to
 /// errors in the source that occurs in the preamble), the number of
 /// reparses during which we'll skip even trying to precompile the
@@ -1100,7 +1078,6 @@
   // Clear out old caches and data.
   TopLevelDecls.clear();
   clearFileLevelDecls();
-  CleanTemporaryFiles();
 
   if (!OverrideMainBuffer) {
 checkAndRemoveNonDriverDiags(StoredDiagnostics);
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -419,7 +419,6 @@
   
   explicit ASTUnit(bool MainFileIsAST);
 
-  void CleanTemporaryFiles();
   bool Parse(std::shared_ptr PCHContainerOps,
  std::unique_ptr OverrideMainBuffer);
 


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -84,13 +84,6 @@
 /// \brief The file in which the precompiled preamble is stored.
 std::string PreambleFile;
 
-/// \brief Temporary files that should be removed when the ASTUnit is
-/// destroyed.
-SmallVector TemporaryFiles;
-
-/// \brief Erase temporary files.
-void CleanTemporaryFiles();
-
 /// \brief Erase the preamble file.
 void CleanPreambleFile();
 
@@ -163,21 +156,14 @@
   return getOnDiskData(AU).PreambleFile;  
 }
 
-void OnDiskData::CleanTemporaryFiles() {
-  for (StringRef File : TemporaryFiles)
-llvm::sys::fs::remove(File);
-  TemporaryFiles.clear();
-}
-
 void OnDiskData::CleanPreambleFile() {
   if (!PreambleFile.empty()) {
 llvm::sys::fs::remove(PreambleFile);
 PreambleFile.clear();
   }
 }
 
 void OnDiskData::Cleanup() {
-  CleanTemporaryFiles();
   CleanPreambleFile();
 }
 
@@ -194,14 +180,6 @@
   llvm::DeleteContainerSeconds(FileDecls);
 }
 
-void ASTUnit::CleanTemporaryFiles() {
-  getOnDiskData(this).CleanTemporaryFiles();
-}
-
-void ASTUnit::addTemporaryFile(StringRef TempFile) {
-  getOnDiskData(this).TemporaryFiles.push_back(TempFile);
-}
-
 /// \brief After failing to build a precompiled preamble (due to
 /// errors in the source that occurs in the preamble), the number of
 /// reparses during which we'll skip even trying to precompile the
@@ -1100,7 +1078,6 @@
   // Clear out old caches and data.
   TopLevelDecls.clear();
   clearFileLevelDecls();
-  CleanTemporaryFiles();
 
   if (!OverrideMainBuffer) {
 checkAndRemoveNonDriverDiags(StoredDiagnostics);
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -419,7 +419,6 @@
   
   explicit ASTUnit(bool MainFileIsAST);
 
-  void CleanTemporaryFiles();
   bool Parse(std::shared_ptr PCHContainerOps,
  std::unique_ptr OverrideMainBuffer);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32439: Fix for incorrect source position of dependent c'tor initializer (bug:26195)

2017-05-17 Thread Serge Preis via Phabricator via cfe-commits
Serge_Preis added a comment.

Hello Richard,

This is just friendly ping. Would you please review my fix for source position 
issue in CXXCtorInitializer and related structures or nominate someone as 
appropriate reviewer for this code.

Thank you,
Serge.


https://reviews.llvm.org/D32439



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


[PATCH] D32428: Fix for Itanium mangler issue with templates (bug: 31405)

2017-05-17 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

David, could you please take a look to this patch. It fixes potential issue and 
should have no side effects. If you have no objections, I'll commit it for 
Serge.


https://reviews.llvm.org/D32428



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