[clang] 0bf2da5 - [NFC] Adjust SmallVector.h header to workaround XL build compiler issue

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 12 19:43:33 PST 2021


Author: xling-Liao
Date: 2021-03-12T21:41:36-06:00
New Revision: 0bf2da53c12b3d2bf213f667af74059280a0d661

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

LOG: [NFC] Adjust SmallVector.h header to workaround XL build compiler issue

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/LLVM.h b/clang/include/clang/Basic/LLVM.h
index 02e422051071..4ac2d744af3c 100644
--- a/clang/include/clang/Basic/LLVM.h
+++ b/clang/include/clang/Basic/LLVM.h
@@ -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.

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 575d1143caab..2eaa481cd911 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -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);

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 2606e9f1b185..5ddd54cf2bc6 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -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.


        


More information about the cfe-commits mailing list