[NFC] Adjust SmallVector.h header to workaround XL build compiler issue
authorxling-Liao <Xiangling.Liao@ibm.com>
Fri, 12 Mar 2021 21:19:43 +0000 (15:19 -0600)
committerxling-Liao <Xiangling.Liao@ibm.com>
Sat, 13 Mar 2021 03:41:36 +0000 (21:41 -0600)
In order to prevent further building issues related to the usage of SmallVector
in other compilation unit, this patch adjusts the llvm.h header as a workaround
instead.

Besides, this patch reverts previous workarounds:

1. Revert "[NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX"
This reverts commit 561fb7f60ab631e712c3fb6bbeb47061222c6818.

2.Revert "[clang][cli] Fix build failure in CompilerInvocation"
This reverts commit 8dc70bdcd0fe4efb65876dce0144d9c3386a2f07.

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

clang/include/clang/Basic/LLVM.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Frontend/CompilerInvocation.cpp

index 02e4220..4ac2d74 100644 (file)
@@ -22,6 +22,9 @@
 // None.h includes an enumerator that is desired & cannot be forward declared
 // without a definition of NoneType.
 #include "llvm/ADT/None.h"
+// Add this header as a workaround to prevent `too few template arguments for
+// class template 'SmallVector'` building error with build compilers like XL.
+#include "llvm/ADT/SmallVector.h"
 
 namespace llvm {
   // ADT's.
index 575d114..2eaa481 100644 (file)
@@ -1913,7 +1913,7 @@ static llvm::CallInst *
 emitCapturedStmtCall(CodeGenFunction &ParentCGF, EmittedClosureTy Cap,
                      llvm::ArrayRef<llvm::Value *> Args) {
   // Append the closure context to the argument.
-  llvm::SmallVector<llvm::Value *> EffectiveArgs;
+  SmallVector<llvm::Value *> EffectiveArgs;
   EffectiveArgs.reserve(Args.size() + 1);
   llvm::append_range(EffectiveArgs, Args);
   EffectiveArgs.push_back(Cap.second);
index 2606e9f..5ddd54c 100644 (file)
@@ -663,7 +663,7 @@ static bool RoundTrip(ParseFn Parse, GenerateFn Generate,
   // Generate arguments from the dummy invocation. If Generate is the
   // inverse of Parse, the newly generated arguments must have the same
   // semantics as the original.
-  SmallVector<const char *, 16> GeneratedArgs1;
+  SmallVector<const char *> GeneratedArgs1;
   Generate(DummyInvocation, GeneratedArgs1, SA);
 
   // Run the second parse, now on the generated arguments, and with the real
@@ -683,7 +683,7 @@ static bool RoundTrip(ParseFn Parse, GenerateFn Generate,
 
   // Generate arguments again, this time from the options we will end up using
   // for the rest of the compilation.
-  SmallVector<const char *, 16> GeneratedArgs2;
+  SmallVector<const char *> GeneratedArgs2;
   Generate(RealInvocation, GeneratedArgs2, SA);
 
   // Compares two lists of generated arguments.