Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8860107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:12:18+00:00 2026-06-14T15:12:18+00:00

Look at the LLVM Demo, the offical way to create a constant string is:

  • 0

Look at the LLVM Demo, the offical way to create a constant string is:

Constant* consStr = ConstantArray::get(mod->getContext(), “hello”, true);

However, it doesn’t work! I aways get compile error about:

test.cc:860:78: error: no matching function for call to llvm::ConstantArray::get(llvm::LLVMContext&, char*&, bool)’
/remote/vgrnd66/wli/Tools/llvm-3.1/include/llvm/Constants.h:354:20: note: candidate is: static llvm::Constant* llvm::ConstantArray::get(llvm::ArrayType*, llvm::ArrayRef<llvm::Constant*>)

Look at the llvm source code, there is no member function to support

llvm::ConstantArray::get(llvm::LLVMContext&, char*&, bool)

I am using llvm3.1.

Is there anything wrong with my code or this constructor has been removed in new source?

Here is the LLVM source code difference.

LLVM2.8

class ConstantArray : public Constant {

  // ConstantArray accessors
  static Constant *get(const ArrayType *T, const std::vector<Constant*> &V);
  static Constant *get(const ArrayType *T, Constant *const *Vals,
                       unsigned NumVals);

  /// This method constructs a ConstantArray and initializes it with a text
  /// string. The default behavior (AddNull==true) causes a null terminator to
  /// be placed at the end of the array. This effectively increases the length
  /// of the array by one (you've been warned).  However, in some situations
  /// this is not desired so if AddNull==false then the string is copied without
  /// null termination.
  static Constant *get(LLVMContext &Context, StringRef Initializer,
                       bool AddNull = true);
}

LLVM3.1

class ConstantArray : public Constant {
public:
  // ConstantArray accessors
  static Constant *get(ArrayType *T, ArrayRef<Constant*> V);

}

Apparently, there are 3 constructor in 2.8 but only one constructor in 3.1 for ConstantArray. Now I don’t know how to create a constant string… 🙁

Any help is appreicated!

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:12:19+00:00Added an answer on June 14, 2026 at 3:12 pm

    OK. I found it has been moved to ConstantDataArray. It seems the LLVM demo cgi is out-of-date:).

    class ConstantDataArray : public ConstantDataSequential {
      /// getString - This method constructs a CDS and initializes it with a text
      /// string. The default behavior (AddNull==true) causes a null terminator to
      /// be placed at the end of the array (increasing the length of the string by
      /// one more than the StringRef would normally indicate.  Pass AddNull=false
      /// to disable this behavior.
      static Constant *getString(LLVMContext &Context, StringRef Initializer,
                                 bool AddNull = true);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

look at these code: public static String get(String url, Properties parameters) throws MalformedURLException, IOException{
Look the mapping below. When I do : session.Get<Customer>(theId); The result return is the
Look at the following example: string foo(int i) { string a; ... Process i
Look this what i have string imagePath = http:// & ConfigurationManager.AppSettings(DomainName) & /images/ htmlstring
Look, before I get comments about how stupid I am for asking a question
Look please at this code: public static void main(String[] args) { String[] array =
Look at the following code: class A { public string DoSomething(string str) { return
look at the following simple code: #include <iostream> #include <string> using namespace std; int
I'm trying to add a metadata string to my LLVM module. The stripped down
Look at this django code: filtered = Question.objects.filter(children__marked=True).distinct() return Question.objects.exclude(id__in=filtered) It returns the list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.